Improve powerline-config help and require --shell argument

This commit is contained in:
ZyX 2014-10-25 17:06:48 +04:00
parent fadd1eec17
commit e58aa8f62d

View File

@ -6,14 +6,26 @@ import argparse
import powerline.bindings.config as config import powerline.bindings.config as config
class StrFunction(object):
def __init__(self, function, name=None):
self.name = name or function.__name__
self.function = function
def __call__(self, *args, **kwargs):
self.function(*args, **kwargs)
def __str__(self):
return self.name
TMUX_ACTIONS = { TMUX_ACTIONS = {
'source': config.source_tmux_files, 'source': StrFunction(config.source_tmux_files, 'source'),
} }
SHELL_ACTIONS = { SHELL_ACTIONS = {
'command': config.shell_command, 'command': StrFunction(config.shell_command, 'command'),
'uses': config.uses, 'uses': StrFunction(config.uses),
} }
@ -56,7 +68,7 @@ def get_argparser(ArgumentParser=ConfigArgParser):
) )
shell_parser.add_argument( shell_parser.add_argument(
'-s', '--shell', '-s', '--shell',
nargs='?', metavar='SHELL',
help='Shell for which query is run', help='Shell for which query is run',
) )
return parser return parser