diff --git a/amanuensis/__main__.py b/amanuensis/__main__.py index 513830d..41052e7 100644 --- a/amanuensis/__main__.py +++ b/amanuensis/__main__.py @@ -33,7 +33,7 @@ def get_parser(valid_commands): # whether their argument is an ArgumentParser. for name, func in valid_commands.items(): # Create the subparser. - cmd = subp.add_parser(name) + cmd = subp.add_parser(name, description=func.__doc__) # Delegate subparser setup. func(cmd) # Store function for later execution diff --git a/amanuensis/cli.py b/amanuensis/cli.py index 67c0465..ecce1f6 100644 --- a/amanuensis/cli.py +++ b/amanuensis/cli.py @@ -1,21 +1,28 @@ # Standard library imports from argparse import ArgumentParser as AP +from functools import wraps def add_argument(*args, **kwargs): def argument_adder(command): + @wraps(command) def augmented_command(cmd_args): if type(cmd_args) is AP: cmd_args.add_argument(*args, **kwargs) else: command(cmd_args) - augmented_command.__doc__ = command.__doc__ return augmented_command return argument_adder +def no_argument(command): + @wraps(command) + def augmented_command(cmd_args): + if type(cmd_args) is not AP: + command(cmd_args) + return augmented_command + @add_argument("--foo", action="store_true") def command_a(args): """a docstring""" print(args.foo) -