diff options
Diffstat (limited to 'examples/read_input.py')
-rw-r--r-- | examples/read_input.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/read_input.py b/examples/read_input.py index e772a106..6fe6b99a 100644 --- a/examples/read_input.py +++ b/examples/read_input.py @@ -10,13 +10,14 @@ import cmd2 EXAMPLE_COMMANDS = "Example Commands" +@cmd2.with_default_category(EXAMPLE_COMMANDS) class ReadInputApp(cmd2.Cmd): def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.prompt = "\n" + self.prompt self.custom_history = ['history 1', 'history 2'] - @cmd2.with_category(EXAMPLE_COMMANDS) + # @cmd2.with_category(EXAMPLE_COMMANDS) def do_basic(self, _) -> None: """Call read_input with no history or tab completion""" self.poutput("Tab completion and up-arrow history is off") @@ -36,7 +37,7 @@ class ReadInputApp(cmd2.Cmd): else: self.custom_history.append(input_str) - @cmd2.with_category(EXAMPLE_COMMANDS) + # @cmd2.with_category(EXAMPLE_COMMANDS) def do_commands(self, _) -> None: """Call read_input the same way cmd2 prompt does to read commands""" self.poutput("Tab completing and up-arrow history configured for commands") @@ -45,7 +46,7 @@ class ReadInputApp(cmd2.Cmd): except EOFError: pass - @cmd2.with_category(EXAMPLE_COMMANDS) + # @cmd2.with_category(EXAMPLE_COMMANDS) def do_custom_choices(self, _) -> None: """Call read_input to use custom history and choices""" self.poutput("Tab completing with static choices list and using custom history") @@ -62,7 +63,7 @@ class ReadInputApp(cmd2.Cmd): """Example choices provider function""" return ["from_provider_1", "from_provider_2", "from_provider_3"] - @cmd2.with_category(EXAMPLE_COMMANDS) + # @cmd2.with_category(EXAMPLE_COMMANDS) def do_custom_choices_provider(self, _) -> None: """Call read_input to use custom history and choices provider function""" self.poutput("Tab completing with choices from provider function and using custom history") @@ -74,7 +75,7 @@ class ReadInputApp(cmd2.Cmd): else: self.custom_history.append(input_str) - @cmd2.with_category(EXAMPLE_COMMANDS) + # @cmd2.with_category(EXAMPLE_COMMANDS) def do_custom_completer(self, _) -> None: """all read_input to use custom history and completer function""" self.poutput("Tab completing paths and using custom history") @@ -85,7 +86,7 @@ class ReadInputApp(cmd2.Cmd): except EOFError: pass - @cmd2.with_category(EXAMPLE_COMMANDS) + # @cmd2.with_category(EXAMPLE_COMMANDS) def do_custom_parser(self, _) -> None: """Call read_input to use a custom history and an argument parser""" parser = cmd2.Cmd2ArgumentParser(prog='', description="An example parser") |