From 9ad174a173fdc610c661d588c1f42decbb3d7f5e Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Sun, 14 Jun 2020 11:05:24 -0400 Subject: Fixes issue with locating help_ annd complete_ functions when autoloading command functions Adds handling of some edge cases. More thorough test coverage. --- examples/modular_commands/commandset_basic.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'examples/modular_commands') diff --git a/examples/modular_commands/commandset_basic.py b/examples/modular_commands/commandset_basic.py index 8b51b7e4..01ce1b39 100644 --- a/examples/modular_commands/commandset_basic.py +++ b/examples/modular_commands/commandset_basic.py @@ -11,8 +11,21 @@ from cmd2.utils import CompletionError @register_command @with_category("AAA") def do_unbound(cmd: Cmd, statement: Statement): + """This is an example of registering an unbound function + + :param cmd: + :param statement: + :return: + """ + cmd.poutput('Unbound Command: {}'.format(statement.args)) + + +@register_command +@with_category("AAA") +def do_func_with_help(cmd: Cmd, statement: Statement): """ This is an example of registering an unbound function + :param cmd: :param statement: :return: @@ -20,6 +33,10 @@ def do_unbound(cmd: Cmd, statement: Statement): cmd.poutput('Unbound Command: {}'.format(statement.args)) +def help_func_with_help(cmd: Cmd): + cmd.poutput('Help for func_with_help') + + @with_default_category('Basic Completion') class BasicCompletionCommandSet(CommandSet): # List of strings used with completion functions -- cgit v1.2.1