summaryrefslogtreecommitdiff
path: root/examples/subcommands.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/subcommands.py')
-rwxr-xr-xexamples/subcommands.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/subcommands.py b/examples/subcommands.py
index 67b06e18..e77abc61 100755
--- a/examples/subcommands.py
+++ b/examples/subcommands.py
@@ -9,7 +9,7 @@ and provides separate contextual help.
import argparse
import cmd2
-from cmd2 import with_argument_parser
+from cmd2 import with_argparser
class SubcommandsExample(cmd2.Cmd):
@@ -19,11 +19,11 @@ class SubcommandsExample(cmd2.Cmd):
cmd2.Cmd.__init__(self)
# sub-command functions for the base command
- def foo(self, args):
+ def base_foo(self, args):
"""foo subcommand of base command"""
self.poutput(args.x * args.y)
- def bar(self, args):
+ def base_bar(self, args):
"""bar sucommand of base command"""
self.poutput('((%s))' % args.z)
@@ -35,17 +35,17 @@ class SubcommandsExample(cmd2.Cmd):
parser_foo = base_subparsers.add_parser('foo', help='foo help')
parser_foo.add_argument('-x', type=int, default=1, help='integer')
parser_foo.add_argument('y', type=float, help='float')
- parser_foo.set_defaults(func=foo)
+ parser_foo.set_defaults(func=base_foo)
# create the parser for the "bar" sub-command
parser_bar = base_subparsers.add_parser('bar', help='bar help')
parser_bar.add_argument('z', help='string')
- parser_bar.set_defaults(func=bar)
+ parser_bar.set_defaults(func=base_bar)
# Create a list of subcommand names, which is used to enable tab-completion of sub-commands
subcommands = ['foo', 'bar']
- @with_argument_parser(base_parser, subcommands)
+ @with_argparser(base_parser, subcommands)
def do_base(self, args):
"""Base command help"""
try: