From eee2d621abfb3d6455570b540069a4853a68f8c6 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Mon, 15 Jan 2018 12:11:12 -0500 Subject: Changed @with_argument_parser to only pass single argument to commands Also added another @with_argparser_and_list decorator that uses argparse.parse_known_args to pass two arguments to a command: both the argparse output and a list of unknown/unmatched args. --- examples/example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/example.py') diff --git a/examples/example.py b/examples/example.py index 7c78edc3..4ba0d29a 100755 --- a/examples/example.py +++ b/examples/example.py @@ -45,7 +45,7 @@ class CmdLineApp(Cmd): speak_parser.add_argument('words', nargs='+', help='words to say') @with_argument_parser(speak_parser) - def do_speak(self, cmdline, opts=None): + def do_speak(self, args): """Repeats what you tell me to.""" words = [] for word in args.words: @@ -67,7 +67,7 @@ class CmdLineApp(Cmd): mumble_parser.add_argument('words', nargs='+', help='words to say') @with_argument_parser(mumble_parser) - def do_mumble(self, cmdline, args=None): + def do_mumble(self, args): """Mumbles what you tell me to.""" repetitions = args.repeat or 1 for i in range(min(repetitions, self.maxrepeats)): -- cgit v1.2.1