Replace underscores with dashes in long options

Fixes #1125
This commit is contained in:
ZyX 2015-01-06 16:29:54 +03:00
parent 16bf16478c
commit 09afbc4655
10 changed files with 43 additions and 43 deletions

View File

@ -53,7 +53,7 @@ Powerline script has a number of options controlling powerline behavior. Here
If ``VALUE`` is omitted then corresponding key will be removed from the
configuration (if it was present).
``-t THEME_NAME.KEY.NESTED_KEY=VALUE`` or ``--theme_option=THEME_NAME.KEY.NESTED_KEY=VALUE``
``-t THEME_NAME.KEY.NESTED_KEY=VALUE`` or ``--theme-option=THEME_NAME.KEY.NESTED_KEY=VALUE``
Overrides options from :file:`powerline/themes/{ext}/{THEME_NAME}.json`.
``KEY.NESTED_KEY=VALUE`` is processed like described above, ``{ext}`` is the
first argument to powerline script. May be passed multiple times.
@ -61,7 +61,7 @@ Powerline script has a number of options controlling powerline behavior. Here
If ``VALUE`` is omitted then corresponding key will be removed from the
configuration (if it was present).
``-p PATH`` or ``--config_path=PATH``
``-p PATH`` or ``--config-path=PATH``
Sets directory where configuration should be read from. If present, no
default locations are searched for configuration. No expansions are
performed by powerline script itself, but ``-p ~/.powerline`` will likely be

View File

@ -43,10 +43,10 @@ _powerline_local_prompt() {
# Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme
$POWERLINE_COMMAND shell $1 \
$2 \
--last_exit_code=$3 \
--last-exit-code=$3 \
--jobnum=$4 \
--renderer_arg="client_id=$$" \
--renderer_arg="local_theme=$5"
--renderer-arg="client_id=$$" \
--renderer-arg="local_theme=$5"
}
_powerline_prompt() {
@ -54,9 +54,9 @@ _powerline_prompt() {
$POWERLINE_COMMAND shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \
-r.bash \
--last_exit_code=$2 \
--last-exit-code=$2 \
--jobnum=$3 \
--renderer_arg="client_id=$$"
--renderer-arg="client_id=$$"
}
_powerline_set_prompt() {

View File

@ -44,12 +44,12 @@ function powerline-setup
end
end
function --on-variable POWERLINE_COMMAND _powerline_update
set -l addargs "--last_exit_code=\$status"
set -l addargs "$addargs --last_pipe_status=\$status"
set -l addargs "--last-exit-code=\$status"
set -l addargs "$addargs --last-pipe-status=\$status"
set -l addargs "$addargs --jobnum=(jobs -p | wc -l)"
# One random value has an 1/32767 = 0.0031% probability of having
# the same value in two shells
set -l addargs "$addargs --renderer_arg=client_id="(random)
set -l addargs "$addargs --renderer-arg=client_id="(random)
set -l addargs "$addargs --width=\$_POWERLINE_COLUMNS"
set -l promptside
set -l rpromptpast

View File

@ -138,10 +138,10 @@ _powerline_local_prompt() {
_powerline_set_jobs
$POWERLINE_COMMAND shell $1 \
$_POWERLINE_RENDERER_ARG \
--renderer_arg="client_id=$$" \
--last_exit_code=$2 \
--renderer-arg="client_id=$$" \
--last-exit-code=$2 \
--jobnum=$_POWERLINE_JOBS \
--renderer_arg="local_theme=$3"
--renderer-arg="local_theme=$3"
}
_powerline_prompt() {
@ -150,8 +150,8 @@ _powerline_prompt() {
$POWERLINE_COMMAND shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \
$_POWERLINE_RENDERER_ARG \
--renderer_arg="client_id=$$" \
--last_exit_code=$2 \
--renderer-arg="client_id=$$" \
--last-exit-code=$2 \
--jobnum=$_POWERLINE_JOBS
_powerline_update_psN
}

View File

@ -36,11 +36,11 @@ if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then
if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then
alias _powerline_above true
else
alias _powerline_above '$POWERLINE_COMMAND shell above --renderer_arg=client_id=$$ --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS'
alias _powerline_above '$POWERLINE_COMMAND shell above --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS'
endif
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r .tcsh --renderer_arg=client_id=$$ --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"'
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r .tcsh --renderer_arg=client_id=$$ --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "'
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"'
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "'
alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`'
alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt'

View File

@ -140,14 +140,14 @@ _powerline_setup_prompt() {
fi
local add_args='-r .zsh'
add_args+=' --last_exit_code=$?'
add_args+=' --last_pipe_status="$pipestatus"'
add_args+=' --renderer_arg="client_id=$$"'
add_args+=' --renderer_arg="shortened_path=${(%):-%~}"'
add_args+=' --last-exit-code=$?'
add_args+=' --last-pipe-status="$pipestatus"'
add_args+=' --renderer-arg="client_id=$$"'
add_args+=' --renderer-arg="shortened_path=${(%):-%~}"'
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
local new_args_2=' --renderer_arg="parser_state=${(%%):-%_}"'
new_args_2+=' --renderer_arg="local_theme=continuation"'
local add_args_3=$add_args' --renderer_arg="local_theme=select"'
local new_args_2=' --renderer-arg="parser_state=${(%%):-%_}"'
new_args_2+=' --renderer-arg="local_theme=continuation"'
local add_args_3=$add_args' --renderer-arg="local_theme=select"'
local add_args_2=$add_args$new_args_2
add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} ))'
local add_args_r2=$add_args$new_args_2

View File

@ -43,7 +43,7 @@ class ConfigArgParser(argparse.ArgumentParser):
def get_argparser(ArgumentParser=ConfigArgParser):
parser = ArgumentParser(description='Script used to obtain powerline configuration.')
parser.add_argument('-p', '--config_path', action='append', metavar='PATH', help='Path to configuration directory. If it is present then configuration files will only be seeked in the provided path. May be provided multiple times to search in a list of directories.')
parser.add_argument('-p', '--config-path', action='append', metavar='PATH', help='Path to configuration directory. If it is present then configuration files will only be seeked in the provided path. May be provided multiple times to search in a list of directories.')
subparsers = parser.add_subparsers()
tmux_parser = subparsers.add_parser('tmux', help='Tmux-specific commands')
tmux_parser.add_argument(

View File

@ -36,17 +36,17 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
parser.add_argument('ext', nargs=1, help='Extension: application for which powerline command is launched (usually `shell\' or `tmux\').')
parser.add_argument('side', nargs='?', choices=('left', 'right', 'above', 'aboveleft'), help='Side: `left\' and `right\' represent left and right side respectively, `above\' emits lines that are supposed to be printed just above the prompt and `aboveleft\' is like concatenating `above\' with `left\' with the exception that only one Python instance is used in this case.')
parser.add_argument(
'-r', '--renderer_module', metavar='MODULE', type=str,
'-r', '--renderer-module', metavar='MODULE', type=str,
help='Renderer module. Usually something like `.bash\' or `.zsh\', is supposed to be set only in shell-specific bindings file.'
)
parser.add_argument('-w', '--width', type=int, help='Maximum prompt with. Triggers truncation of some segments.')
parser.add_argument('--last_exit_code', metavar='INT', type=int, help='Last exit code.')
parser.add_argument('--last_pipe_status', metavar='LIST', default='', type=lambda s: [int(status) for status in s.split()], help='Like above, but is supposed to contain space-separated array of statuses, representing exit statuses of commands in one pipe.')
parser.add_argument('--last-exit-code', metavar='INT', type=int, help='Last exit code.')
parser.add_argument('--last-pipe-status', metavar='LIST', default='', type=lambda s: [int(status) for status in s.split()], help='Like above, but is supposed to contain space-separated array of statuses, representing exit statuses of commands in one pipe.')
parser.add_argument('--jobnum', metavar='INT', type=int, help='Number of jobs.')
parser.add_argument('-c', '--config', metavar='KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Configuration overrides for `config.json\'. Is translated to a dictionary and merged with the dictionary obtained from actual JSON configuration: KEY.KEY=VALUE is translated to `{"KEY": {"KEY": VALUE}}\' and then merged recursively. VALUE may be any JSON value, values that are not `null\', `true\', `false\', start with digit, `{\', `[\' are treated like strings. If VALUE is omitted then corresponding key is removed.')
parser.add_argument('-t', '--theme_option', metavar='THEME.KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Like above, but theme-specific. THEME should point to an existing and used theme to have any effect, but it is fine to use any theme here.')
parser.add_argument('-R', '--renderer_arg', metavar='KEY=VAL', type=arg_to_unicode, action='append', help='Like above, but provides argument for renderer. Is supposed to be used only by shell bindings to provide various data like last_exit_code or last_pipe_status (they are not using `--renderer_arg\' for historical resons: `--renderer_arg\' was added later).')
parser.add_argument('-p', '--config_path', action='append', metavar='PATH', help='Path to configuration directory. If it is present then configuration files will only be seeked in the provided path. May be provided multiple times to search in a list of directories.')
parser.add_argument('-t', '--theme-option', metavar='THEME.KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Like above, but theme-specific. THEME should point to an existing and used theme to have any effect, but it is fine to use any theme here.')
parser.add_argument('-R', '--renderer-arg', metavar='KEY=VAL', type=arg_to_unicode, action='append', help='Like above, but provides argument for renderer. Is supposed to be used only by shell bindings to provide various data like last-exit-code or last-pipe-status (they are not using `--renderer-arg\' for historical resons: `--renderer-arg\' was added later).')
parser.add_argument('-p', '--config-path', action='append', metavar='PATH', help='Path to configuration directory. If it is present then configuration files will only be seeked in the provided path. May be provided multiple times to search in a list of directories.')
parser.add_argument('--socket', metavar='ADDRESS', type=str, help='Socket address to use in daemon clients. Is always UNIX domain socket on linux and file socket on Mac OS X. Not used here, present only for compatibility with other powerline clients. This argument must always be the first one and be in a form `--socket ADDRESS\': no `=\' or short form allowed (in other powerline clients, not here).')
return parser

View File

@ -157,7 +157,7 @@ Returns a segment list to create a breadcrumb-like effect.
:param bool use_path_separator:
Use path separator in place of soft divider.
:param bool use_shortened_path:
Use path from shortened_path ``--renderer_arg`` argument. If this argument
Use path from shortened_path ``--renderer-arg`` argument. If this argument
is present ``shorten_home`` argument is ignored.
:param bool shorten_home:
Shorten home directory to ``~``.

View File

@ -37,18 +37,18 @@ class TestParser(TestCase):
(['shell', '-t'], 'expected one argument'),
(['shell', '-p'], 'expected one argument'),
(['shell', '-R'], 'expected one argument'),
(['shell', '--renderer_module'], 'expected one argument'),
(['shell', '--renderer-module'], 'expected one argument'),
(['shell', '--width'], 'expected one argument'),
(['shell', '--last_exit_code'], 'expected one argument'),
(['shell', '--last_pipe_status'], 'expected one argument'),
(['shell', '--last-exit-code'], 'expected one argument'),
(['shell', '--last-pipe-status'], 'expected one argument'),
(['shell', '--config'], 'expected one argument'),
(['shell', '--theme_option'], 'expected one argument'),
(['shell', '--config_path'], 'expected one argument'),
(['shell', '--renderer_arg'], 'expected one argument'),
(['shell', '--theme-option'], 'expected one argument'),
(['shell', '--config-path'], 'expected one argument'),
(['shell', '--renderer-arg'], 'expected one argument'),
(['shell', '--jobnum'], 'expected one argument'),
(['-r', '.zsh'], 'too few arguments|the following arguments are required: ext'),
(['shell', '--last_exit_code', 'i'], 'invalid int value'),
(['shell', '--last_pipe_status', '1 i'], 'invalid <lambda> value'),
(['shell', '--last-exit-code', 'i'], 'invalid int value'),
(['shell', '--last-pipe-status', '1 i'], 'invalid <lambda> value'),
]:
self.assertRaises(SystemExit, parser.parse_args, raising_args)
self.assertFalse(out.getvalue())
@ -67,8 +67,8 @@ class TestParser(TestCase):
'shell',
'left',
'-r', '.zsh',
'--last_exit_code', '10',
'--last_pipe_status', '10 20 30',
'--last-exit-code', '10',
'--last-pipe-status', '10 20 30',
'--jobnum=10',
'-w', '100',
'-c', 'common.term_truecolor=true',