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/argparse_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/argparse_example.py')
-rwxr-xr-x | examples/argparse_example.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/argparse_example.py b/examples/argparse_example.py index b203feef..ae45411c 100755 --- a/examples/argparse_example.py +++ b/examples/argparse_example.py @@ -48,7 +48,7 @@ class CmdLineApp(Cmd): speak_parser.add_argument('words', nargs='+', help='words to say') @with_argument_parser(speak_parser) - def do_speak(self, arglist, args=None): + def do_speak(self, args): """Repeats what you tell me to.""" words = [] for word in args.words: @@ -69,7 +69,7 @@ class CmdLineApp(Cmd): tag_parser.add_argument('content', nargs='+', help='content to surround with tag') @with_argument_parser(tag_parser) - def do_tag(self, arglist, args=None): + def do_tag(self, args): """create a html tag""" self.poutput('<{0}>{1}</{0}>'.format(args.tag[0], ' '.join(args.content))) |