Format powerline/commands/main.py to make it more readable
This commit is contained in:
parent
afcd8e4f46
commit
2faa1584d6
|
@ -65,21 +65,85 @@ def int_or_sig(s):
|
|||
|
||||
def get_argparser(ArgumentParser=argparse.ArgumentParser):
|
||||
parser = ArgumentParser(description='Powerline prompt and statusline script.')
|
||||
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(
|
||||
'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,
|
||||
help='Renderer module. Usually something like `.bash\' or `.zsh\', is supposed to be set only in shell-specific bindings file.'
|
||||
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_or_sig,
|
||||
help='Last exit code.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--last-pipe-status', metavar='LIST', default='',
|
||||
type=lambda s: [int_or_sig(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-override', 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-override', 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).'
|
||||
)
|
||||
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_or_sig, help='Last exit code.')
|
||||
parser.add_argument('--last-pipe-status', metavar='LIST', default='', type=lambda s: [int_or_sig(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-override', 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-override', 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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue