summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-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())