diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-01-15 12:11:12 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-01-15 12:11:12 -0500 |
commit | eee2d621abfb3d6455570b540069a4853a68f8c6 (patch) | |
tree | 6bfc049369079868eab6f05ce8d0cae233c43cb9 /examples/example.py | |
parent | aec6704db9542e35e4cdc6073210bc0d6c507335 (diff) | |
download | cmd2-git-eee2d621abfb3d6455570b540069a4853a68f8c6.tar.gz |
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.
Diffstat (limited to 'examples/example.py')
-rwxr-xr-x | examples/example.py | 4 |
1 files changed, 2 insertions, 2 deletions
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)): |