summaryrefslogtreecommitdiff
path: root/examples/modular_commands_main.py
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2020-07-07 13:20:54 -0400
committeranselor <anselor@gmail.com>2020-08-04 13:38:08 -0400
commit5e4eec2a2df0726be05718aeb53bb0f9f79969a5 (patch)
treef7abba55d2e9ab6f1ee69ccbec8e8abcaa5e3199 /examples/modular_commands_main.py
parent7eba947dab35716fc59f88bc7b17fdae0de1d1a3 (diff)
downloadcmd2-git-5e4eec2a2df0726be05718aeb53bb0f9f79969a5.tar.gz
cleanup
Diffstat (limited to 'examples/modular_commands_main.py')
-rw-r--r--examples/modular_commands_main.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/modular_commands_main.py b/examples/modular_commands_main.py
index 93dc79ea..9e7f79cc 100644
--- a/examples/modular_commands_main.py
+++ b/examples/modular_commands_main.py
@@ -4,12 +4,12 @@
A simple example demonstrating how to integrate tab completion with argparse-based commands.
"""
import argparse
-from typing import Dict, List
+from typing import Dict, Iterable, List, Optional
-from cmd2 import Cmd, Cmd2ArgumentParser, CompletionItem, with_argparser
+from cmd2 import Cmd, Cmd2ArgumentParser, CommandSet, CompletionItem, with_argparser
from cmd2.utils import CompletionError, basic_complete
from modular_commands.commandset_basic import BasicCompletionCommandSet # noqa: F401
-from modular_commands.commandset_custominit import CustomInitCommandSet
+from modular_commands.commandset_custominit import CustomInitCommandSet # noqa: F401
# Data source for argparse.choices
food_item_strs = ['Pizza', 'Ham', 'Ham Sandwich', 'Potato']
@@ -58,8 +58,8 @@ def choices_arg_tokens(arg_tokens: Dict[str, List[str]]) -> List[str]:
class WithCommandSets(Cmd):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
+ def __init__(self, command_sets: Optional[Iterable[CommandSet]] = None):
+ super().__init__(command_sets=command_sets)
self.sport_item_strs = ['Bat', 'Basket', 'Basketball', 'Football', 'Space Ball']
def choices_method(self) -> List[str]:
@@ -122,6 +122,6 @@ if __name__ == '__main__':
import sys
print("Starting")
- command_sets = [CustomInitCommandSet('First argument', 'Second argument')]
- app = WithCommandSets(command_sets=command_sets)
+ my_sets = [CustomInitCommandSet('First argument', 'Second argument')]
+ app = WithCommandSets(command_sets=my_sets)
sys.exit(app.cmdloop())