Improve powerline-lemonbar documentation

Changes:

- Usage determination transferred back to argparse (it wraps).
- Added complete description of lemonbar script to wm-widgets.rst.
- --interval and --height got their arguments clarified by metavar: it was not
  clear what units they use.
- --bar-command got its metavar because it is better then default BAR_COMMAND.
- --bar-command short variant is now -C.
This commit is contained in:
Foo 2016-01-08 04:24:51 +03:00 committed by S0lll0s
parent 8168ad1428
commit 646b0ea5ea
4 changed files with 46 additions and 30 deletions

View File

@ -73,6 +73,12 @@ Running the binding in i3-mode will require `i3ipc <https://github.com/acrisci/i
See the `lemonbar documentation <https://github.com/LemonBoy/bar>`_ for more See the `lemonbar documentation <https://github.com/LemonBoy/bar>`_ for more
information and options. information and options.
All ``powerline-lemonbar.py`` arguments:
.. automan:: powerline.commands.lemonbar
:prog: powerline-lemonbar.py
:minimal: true
I3 bar I3 bar
====== ======

View File

@ -7,39 +7,14 @@ import re
import subprocess import subprocess
from threading import Lock, Timer from threading import Lock, Timer
from argparse import ArgumentParser, REMAINDER
from powerline.lemonbar import LemonbarPowerline from powerline.lemonbar import LemonbarPowerline
from powerline.lib.shell import run_cmd from powerline.lib.shell import run_cmd
from powerline.commands.lemonbar import get_argparser
if __name__ == '__main__': if __name__ == '__main__':
parser = ArgumentParser( parser = get_argparser()
description='Powerline BAR bindings.',
usage='%(prog)s [-h] [--i3] [--height HEIGHT] [--interval INTERVAL] [--bar-command CMD] -- args'
)
parser.add_argument(
'--i3', action='store_true',
help='Subscribe for i3 events.'
)
parser.add_argument(
'--height', default='',
help='Bar height.'
)
parser.add_argument(
'--interval', '-i',
type=float, default=0.5,
help='Refresh interval.'
)
parser.add_argument(
'--bar-command', '-c',
default='lemonbar',
help='Name of the lemonbar executable to use.'
)
parser.add_argument(
'args', nargs=REMAINDER,
help='Extra arguments for lemonbar.'
)
args = parser.parse_args() args = parser.parse_args()
powerline = LemonbarPowerline() powerline = LemonbarPowerline()

View File

@ -0,0 +1,35 @@
# vim:fileencoding=utf-8:noet
# WARNING: using unicode_literals causes errors in argparse
from __future__ import (division, absolute_import, print_function)
import argparse
def get_argparser(ArgumentParser=argparse.ArgumentParser):
parser = ArgumentParser(
description='Powerline BAR bindings.'
)
parser.add_argument(
'--i3', action='store_true',
help='Subscribe for i3 events.'
)
parser.add_argument(
'--height', default='',
metavar='PIXELS', help='Bar height.'
)
parser.add_argument(
'--interval', '-i',
type=float, default=0.5,
metavar='SECONDS', help='Refresh interval.'
)
parser.add_argument(
'--bar-command', '-C',
default='lemonbar',
metavar='CMD', help='Name of the lemonbar executable to use.'
)
parser.add_argument(
'args', nargs=argparse.REMAINDER,
help='Extra arguments for lemonbar. Should be preceded with ``--`` '
'argument in order not to be confused with script own arguments.'
)
return parser

View File

@ -117,7 +117,7 @@ if ! test -e "$LEMONBAR_SCRIPT" ; then
: :
else else
enter_suite "lemonbar" enter_suite "lemonbar"
for args in "" "-i0.5" "--interval=0.5" "-- test args" "-c bar-aint-recursive" "--height=10"; do for args in "" "-i0.5" "--interval=0.5" "-- test args" "--bar-command bar-aint-recursive" "--height=10"; do
rm -rf "$TEST_ROOT/results" rm -rf "$TEST_ROOT/results"
run python "$LEMONBAR_SCRIPT" $args > "$TEST_ROOT/lemonbar.log" 2>&1 & run python "$LEMONBAR_SCRIPT" $args > "$TEST_ROOT/lemonbar.log" 2>&1 &
SPID=$! SPID=$!
@ -158,8 +158,8 @@ else
height="${height%% *}" height="${height%% *}"
fi fi
command="lemonbar" command="lemonbar"
if test "x${args#-c}" != "x$args" ; then if test "x${args#--bar-command}" != "x$args" ; then
command="${args#-c}" command="${args#--bar-command}"
command="${command# }" command="${command# }"
command="${command#=}" command="${command#=}"
command="${command%% *}" command="${command%% *}"