diff options
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 6b085a98..869b7b04 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2057,8 +2057,8 @@ class Cmd(cmd.Cmd): return self.do_shell(statement.command_and_args) else: - self.perror('*** {} is not a recognized command, alias, or macro'.format(statement.command), - err_color=Fore.RESET, traceback_war=False) + self.perror('{} is not a recognized command, alias, or macro'.format(statement.command), + traceback_war=False, err_color=Fore.RESET) def pseudo_raw_input(self, prompt: str) -> str: """Began life as a copy of cmd's cmdloop; like raw_input but @@ -2586,12 +2586,20 @@ class Cmd(cmd.Cmd): else: # Getting help for a specific command func = self.cmd_func(args.command) + help_func = getattr(self, HELP_FUNC_PREFIX + args.command, None) + + # If the command function uses argparse, then use argparse's help if func and hasattr(func, 'argparser'): completer = AutoCompleter(getattr(func, 'argparser'), self) tokens = [args.command] + args.subcommand self.poutput(completer.format_help(tokens)) + + # If there is no help information then print an error + elif help_func is None and (func is None or not func.__doc__): + self.perror("No help on {}".format(args.command), traceback_war=False, err_color=Fore.RESET) + + # Otherwise delegate to cmd base class do_help() else: - # No special behavior needed, delegate to cmd base class do_help() super().do_help(args.command) def _help_menu(self, verbose: bool = False) -> None: @@ -3719,7 +3727,7 @@ class Cmd(cmd.Cmd): :param message_to_print: the message reporting that the command is disabled :param kwargs: not used """ - self.perror(message_to_print, err_color=Fore.RESET, traceback_war=False) + self.perror(message_to_print, traceback_war=False, err_color=Fore.RESET) def cmdloop(self, intro: Optional[str] = None) -> None: """This is an outer wrapper around _cmdloop() which deals with extra features provided by cmd2. |