@@ -2057,8 +2057,8 @@ def default(self, statement: Statement) -> Optional[bool]:
20572057
20582058 return self .do_shell (statement .command_and_args )
20592059 else :
2060- self .perror ('*** {} is not a recognized command, alias, or macro' .format (statement .command ),
2061- err_color = Fore .RESET , traceback_war = False )
2060+ self .perror ('{} is not a recognized command, alias, or macro' .format (statement .command ),
2061+ traceback_war = False , err_color = Fore .RESET )
20622062
20632063 def pseudo_raw_input (self , prompt : str ) -> str :
20642064 """Began life as a copy of cmd's cmdloop; like raw_input but
@@ -2586,12 +2586,20 @@ def do_help(self, args: argparse.Namespace) -> None:
25862586 else :
25872587 # Getting help for a specific command
25882588 func = self .cmd_func (args .command )
2589+ help_func = getattr (self , HELP_FUNC_PREFIX + args .command , None )
2590+
2591+ # If the command function uses argparse, then use argparse's help
25892592 if func and hasattr (func , 'argparser' ):
25902593 completer = AutoCompleter (getattr (func , 'argparser' ), self )
25912594 tokens = [args .command ] + args .subcommand
25922595 self .poutput (completer .format_help (tokens ))
2596+
2597+ # If there is no help information then print an error
2598+ elif help_func is None and (func is None or not func .__doc__ ):
2599+ self .perror ("No help on {}" .format (args .command ), traceback_war = False , err_color = Fore .RESET )
2600+
2601+ # Otherwise delegate to cmd base class do_help()
25932602 else :
2594- # No special behavior needed, delegate to cmd base class do_help()
25952603 super ().do_help (args .command )
25962604
25972605 def _help_menu (self , verbose : bool = False ) -> None :
@@ -3719,7 +3727,7 @@ def _report_disabled_command_usage(self, *args, message_to_print: str, **kwargs)
37193727 :param message_to_print: the message reporting that the command is disabled
37203728 :param kwargs: not used
37213729 """
3722- self .perror (message_to_print , err_color = Fore .RESET , traceback_war = False )
3730+ self .perror (message_to_print , traceback_war = False , err_color = Fore .RESET )
37233731
37243732 def cmdloop (self , intro : Optional [str ] = None ) -> None :
37253733 """This is an outer wrapper around _cmdloop() which deals with extra features provided by cmd2.
0 commit comments