diff options
author | kotfu <kotfu@kotfu.net> | 2018-05-23 21:16:17 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-05-23 21:16:17 -0600 |
commit | 6780baa83457f7e99ba3a9c4f6a3c27701326ac5 (patch) | |
tree | c130136619c740645c45326a2ada0fcffa9f65a2 /examples/arg_print.py | |
parent | 1a70b90f375997751bc7df16b5e3f58c6194c71b (diff) | |
download | cmd2-git-6780baa83457f7e99ba3a9c4f6a3c27701326ac5.tar.gz |
Standardize cmd2 imports in tests and examples
Diffstat (limited to 'examples/arg_print.py')
-rwxr-xr-x | examples/arg_print.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/examples/arg_print.py b/examples/arg_print.py index b2f0fcda..1e6babc1 100755 --- a/examples/arg_print.py +++ b/examples/arg_print.py @@ -11,9 +11,7 @@ It also serves as an example of how to create command aliases (shortcuts). """ import argparse -from cmd2 import cmd2 -from cmd2.cmd2 import with_argument_list, with_argparser, with_argparser_and_unknown_args - +import cmd2 class ArgumentAndOptionPrinter(cmd2.Cmd): """ Example cmd2 application where we create commands that just print the arguments they are called with.""" @@ -31,7 +29,7 @@ class ArgumentAndOptionPrinter(cmd2.Cmd): """Print the argument string this basic command is called with.""" self.poutput('aprint was called with argument: {!r}'.format(arg)) - @with_argument_list + @cmd2.with_argument_list def do_lprint(self, arglist): """Print the argument list this basic command is called with.""" self.poutput('lprint was called with the following list of arguments: {!r}'.format(arglist)) @@ -42,7 +40,7 @@ class ArgumentAndOptionPrinter(cmd2.Cmd): oprint_parser.add_argument('-r', '--repeat', type=int, help='output [n] times') oprint_parser.add_argument('words', nargs='+', help='words to print') - @with_argparser(oprint_parser) + @cmd2.with_argparser(oprint_parser) def do_oprint(self, args): """Print the options and argument list this options command was called with.""" self.poutput('oprint was called with the following\n\toptions: {!r}'.format(args)) @@ -51,13 +49,12 @@ class ArgumentAndOptionPrinter(cmd2.Cmd): pprint_parser.add_argument('-p', '--piglatin', action='store_true', help='atinLay') pprint_parser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE') pprint_parser.add_argument('-r', '--repeat', type=int, help='output [n] times') - @with_argparser_and_unknown_args(pprint_parser) + @cmd2.with_argparser_and_unknown_args(pprint_parser) def do_pprint(self, args, unknown): """Print the options and argument list this options command was called with.""" self.poutput('oprint was called with the following\n\toptions: {!r}\n\targuments: {}'.format(args, unknown)) - if __name__ == '__main__': app = ArgumentAndOptionPrinter() app.cmdloop() |