@@ -338,6 +338,9 @@ class Cmd(cmd.Cmd):
338338 'quiet' : "Don't print nonessential feedback" ,
339339 'timing' : 'Report execution times' }
340340
341+ # Override cmd's nohelp
342+ nohelp = "No help on {}"
343+
341344 def __init__ (self , completekey : str = 'tab' , stdin = None , stdout = None , persistent_history_file : str = '' ,
342345 persistent_history_length : int = 1000 , startup_script : Optional [str ] = None , use_ipython : bool = False ,
343346 transcript_files : Optional [List [str ]] = None ) -> None :
@@ -2057,8 +2060,7 @@ def default(self, statement: Statement) -> Optional[bool]:
20572060
20582061 return self .do_shell (statement .command_and_args )
20592062 else :
2060- self .perror ('{} is not a recognized command, alias, or macro' .format (statement .command ),
2061- traceback_war = False , err_color = Fore .RESET )
2063+ sys .stderr .write ('{} is not a recognized command, alias, or macro\n ' .format (statement .command ))
20622064
20632065 def pseudo_raw_input (self , prompt : str ) -> str :
20642066 """Began life as a copy of cmd's cmdloop; like raw_input but
@@ -2596,7 +2598,8 @@ def do_help(self, args: argparse.Namespace) -> None:
25962598
25972599 # If there is no help information then print an error
25982600 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 )
2601+ err_msg = Cmd .nohelp .format (args .command )
2602+ self .decolorized_write (sys .stderr , "{}\n " .format (err_msg ))
26002603
26012604 # Otherwise delegate to cmd base class do_help()
26022605 else :
@@ -3727,7 +3730,7 @@ def _report_disabled_command_usage(self, *args, message_to_print: str, **kwargs)
37273730 :param message_to_print: the message reporting that the command is disabled
37283731 :param kwargs: not used
37293732 """
3730- self .perror ( message_to_print , traceback_war = False , err_color = Fore . RESET )
3733+ self .decolorized_write ( sys . stderr , "{} \n " . format ( message_to_print ) )
37313734
37323735 def cmdloop (self , intro : Optional [str ] = None ) -> None :
37333736 """This is an outer wrapper around _cmdloop() which deals with extra features provided by cmd2.
0 commit comments