diff --git a/docs/source/powerline_automan.py b/docs/source/powerline_automan.py index 344c955a..b4e1a14f 100644 --- a/docs/source/powerline_automan.py +++ b/docs/source/powerline_automan.py @@ -91,6 +91,10 @@ class AutoManGroup(object): def add_argument(self, *args, **kwargs): self.arguments.append(parse_argument(*args, **kwargs)) + def add_argument_group(self, *args, **kwargs): + self.arguments.append(AutoManGroup()) + return self.arguments[-1] + class SurroundWith(): def __init__(self, ret, condition, start='[', end=']'): diff --git a/powerline/commands/daemon.py b/powerline/commands/daemon.py index 9efcdca2..8147434c 100644 --- a/powerline/commands/daemon.py +++ b/powerline/commands/daemon.py @@ -8,8 +8,9 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser): parser = ArgumentParser(description='Daemon that improves powerline performance.') parser.add_argument('--quiet', '-q', action='store_true', help='Without other options: do not complain about already running powerline-daemon instance. Will still exit with 1. With `--kill\' and `--replace\': do not show any messages. With `--foreground\': ignored. Does not silence exceptions in any case.') parser.add_argument('--socket', '-s', help='Specify socket which will be used for connecting to daemon.') - arggr = parser.add_mutually_exclusive_group().add_argument - arggr('--kill', '-k', action='store_true', help='Kill an already running instance.') - arggr('--foreground', '-f', action='store_true', help='Run in the foreground (don’t daemonize).') - arggr('--replace', '-r', action='store_true', help='Replace an already running instance.') + exclusive_group = parser.add_mutually_exclusive_group() + exclusive_group.add_argument('--kill', '-k', action='store_true', help='Kill an already running instance.') + replace_group = exclusive_group.add_argument_group() + replace_group.add_argument('--foreground', '-f', action='store_true', help='Run in the foreground (don’t daemonize).') + replace_group.add_argument('--replace', '-r', action='store_true', help='Replace an already running instance.') return parser diff --git a/scripts/powerline-daemon b/scripts/powerline-daemon index ad7bd47d..82841878 100755 --- a/scripts/powerline-daemon +++ b/scripts/powerline-daemon @@ -356,7 +356,8 @@ def lockpidfile(): def main(): global address global pidfile - args = get_daemon_argparser().parse_args() + parser = get_daemon_argparser() + args = parser.parse_args() if args.socket: address = args.socket @@ -376,6 +377,8 @@ def main(): pidfile = address + '.pid' if args.kill: + if args.foreground or args.replace: + parser.error('--kill and --foreground/--replace cannot be used together') if kill_daemon(): if not args.quiet: print ('Kill command sent to daemon, if it does not die in a couple of seconds use kill to kill it')