From 4c0bdad9acd578536436246023ae884755089040 Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Tue, 4 Aug 2020 11:56:57 -0400 Subject: Minor formatting fixes. Injecting a function into namespace objects before passing to command handlers to access sub-command handlers --- examples/modular_subcommands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') 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') -- cgit v1.2.1