summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEric Lin <anselor@gmail.com>2020-08-04 11:56:57 -0400
committeranselor <anselor@gmail.com>2020-08-04 13:38:08 -0400
commit4c0bdad9acd578536436246023ae884755089040 (patch)
treecd5e9a4f296982ff870f12023e38a6edd6954d51 /examples
parent2d24953c71f8e850b5925c3923cbb596de4b0813 (diff)
downloadcmd2-git-4c0bdad9acd578536436246023ae884755089040.tar.gz
Minor formatting fixes. Injecting a function into namespace objects before passing to command handlers to access sub-command handlers
Diffstat (limited to 'examples')
-rw-r--r--examples/modular_subcommands.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/modular_subcommands.py b/examples/modular_subcommands.py
index 1ac951ae..e1bc6b7b 100644
--- a/examples/modular_subcommands.py
+++ b/examples/modular_subcommands.py
@@ -95,10 +95,10 @@ class ExampleApp(cmd2.Cmd):
@with_argparser(cut_parser)
def do_cut(self, ns: argparse.Namespace):
- func = getattr(ns, 'handler', None)
- if func is not None:
+ handler = ns.get_handler()
+ if handler is not None:
# Call whatever subcommand function was selected
- func(ns)
+ handler(ns)
else:
# No subcommand was provided, so call help
self.poutput('This command does nothing without sub-parsers registered')