summaryrefslogtreecommitdiff
path: root/examples/subcommands.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2018-04-21 22:29:18 -0400
committerEric Lin <anselor@gmail.com>2018-04-21 22:29:18 -0400
commit965fa83804fec8ba3df8209b253e11acfb015d37 (patch)
tree5e4c3bb9f48f72a24dcddb35fdb83c07428c6d5b /examples/subcommands.py
parent85c2c6bba46900af6012b54c31e650095194b1aa (diff)
downloadcmd2-git-965fa83804fec8ba3df8209b253e11acfb015d37.tar.gz
Switched the default behavior in cmd2 for argparse commands to use the AutoCompleter by default.
Diffstat (limited to 'examples/subcommands.py')
-rwxr-xr-xexamples/subcommands.py11
1 files changed, 1 insertions, 10 deletions
diff --git a/examples/subcommands.py b/examples/subcommands.py
index 03088c93..8cdfb368 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_argparser
+from cmd2 import with_argparser, with_argparser_and_unknown_args
sport_item_strs = ['Bat', 'Basket', 'Basketball', 'Football', 'Space Ball']
@@ -35,12 +35,6 @@ class SubcommandsExample(cmd2.Cmd):
"""sport subcommand of base command"""
self.poutput('Sport is {}'.format(args.sport))
- # noinspection PyUnusedLocal
- def complete_base_sport(self, text, line, begidx, endidx):
- """ Adds tab completion to base sport subcommand """
- index_dict = {1: sport_item_strs}
- return self.index_based_complete(text, line, begidx, endidx, index_dict)
-
# create the top-level parser for the base command
base_parser = argparse.ArgumentParser(prog='base')
base_subparsers = base_parser.add_subparsers(title='subcommands', help='subcommand help')
@@ -81,9 +75,6 @@ class SubcommandsExample(cmd2.Cmd):
# No subcommand was provided, so call help
self.do_help('base')
- # Enable tab completion of base to make sure the subcommands' completers get called.
- # complete_base = cmd2.Cmd.cmd_with_subs_completer
-
if __name__ == '__main__':
app = SubcommandsExample()