diff options
author | Eric Lin <anselor@gmail.com> | 2020-08-12 13:08:59 -0400 |
---|---|---|
committer | anselor <anselor@gmail.com> | 2020-08-12 17:41:20 -0400 |
commit | 774fb39d7e259d0679c573b0d893293f9ed9aed9 (patch) | |
tree | a78a4693e7cca707668eb89b0d8e41c3fedd108e /examples/modular_commands_dynamic.py | |
parent | 4d628ea7573ef9016971dbbf7de9126c6d179227 (diff) | |
download | cmd2-git-774fb39d7e259d0679c573b0d893293f9ed9aed9.tar.gz |
Breaking change: Removed cmd2 app as a required second parameter to
CommandSet command functions (do_, complete_, help_).
Renamed install_command_set and uninstall_command_set to
register_command_set and unregister_command_set.
Diffstat (limited to 'examples/modular_commands_dynamic.py')
-rw-r--r-- | examples/modular_commands_dynamic.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/modular_commands_dynamic.py b/examples/modular_commands_dynamic.py index 81dbad82..eb6283a7 100644 --- a/examples/modular_commands_dynamic.py +++ b/examples/modular_commands_dynamic.py @@ -19,11 +19,11 @@ class LoadableFruits(CommandSet): def __init__(self): super().__init__() - def do_apple(self, cmd: cmd2.Cmd, _: cmd2.Statement): - cmd.poutput('Apple') + def do_apple(self, _: cmd2.Statement): + self._cmd.poutput('Apple') - def do_banana(self, cmd: cmd2.Cmd, _: cmd2.Statement): - cmd.poutput('Banana') + def do_banana(self, _: cmd2.Statement): + self._cmd.poutput('Banana') @with_default_category('Vegetables') @@ -31,11 +31,11 @@ class LoadableVegetables(CommandSet): def __init__(self): super().__init__() - def do_arugula(self, cmd: cmd2.Cmd, _: cmd2.Statement): - cmd.poutput('Arugula') + def do_arugula(self, _: cmd2.Statement): + self._cmd.poutput('Arugula') - def do_bokchoy(self, cmd: cmd2.Cmd, _: cmd2.Statement): - cmd.poutput('Bok Choy') + def do_bokchoy(self, _: cmd2.Statement): + self._cmd.poutput('Bok Choy') class ExampleApp(cmd2.Cmd): @@ -58,14 +58,14 @@ class ExampleApp(cmd2.Cmd): def do_load(self, ns: argparse.Namespace): if ns.cmds == 'fruits': try: - self.install_command_set(self._fruits) + self.register_command_set(self._fruits) self.poutput('Fruits loaded') except ValueError: self.poutput('Fruits already loaded') if ns.cmds == 'vegetables': try: - self.install_command_set(self._vegetables) + self.register_command_set(self._vegetables) self.poutput('Vegetables loaded') except ValueError: self.poutput('Vegetables already loaded') @@ -73,11 +73,11 @@ class ExampleApp(cmd2.Cmd): @with_argparser(load_parser) def do_unload(self, ns: argparse.Namespace): if ns.cmds == 'fruits': - self.uninstall_command_set(self._fruits) + self.unregister_command_set(self._fruits) self.poutput('Fruits unloaded') if ns.cmds == 'vegetables': - self.uninstall_command_set(self._vegetables) + self.unregister_command_set(self._vegetables) self.poutput('Vegetables unloaded') |