@@ -1478,10 +1478,10 @@ def complete(self, text: str, state: int) -> Optional[str]:
14781478
14791479 if compfunc is None :
14801480 # There's no completer function, next see if the command uses argparser
1481- cmd_func = self ._cmd_func (command )
1482- if cmd_func and hasattr (cmd_func , 'argparser' ):
1481+ func = self .cmd_func (command )
1482+ if func and hasattr (func , 'argparser' ):
14831483 compfunc = functools .partial (self ._autocomplete_default ,
1484- argparser = getattr (cmd_func , 'argparser' ))
1484+ argparser = getattr (func , 'argparser' ))
14851485 else :
14861486 compfunc = self .completedefault
14871487
@@ -1665,9 +1665,9 @@ def complete_help(self, text: str, line: str, begidx: int, endidx: int) -> List[
16651665
16661666 # check if the command uses argparser
16671667 elif index >= subcmd_index :
1668- cmd_func = self ._cmd_func (tokens [cmd_index ])
1669- if cmd_func and hasattr (cmd_func , 'argparser' ):
1670- completer = AutoCompleter (getattr (cmd_func , 'argparser' ), cmd2_app = self )
1668+ func = self .cmd_func (tokens [cmd_index ])
1669+ if func and hasattr (func , 'argparser' ):
1670+ completer = AutoCompleter (getattr (func , 'argparser' ), cmd2_app = self )
16711671 matches = completer .complete_command_help (tokens [1 :], text , line , begidx , endidx )
16721672
16731673 return matches
@@ -2002,17 +2002,16 @@ def _restore_output(self, statement: Statement) -> None:
20022002
20032003 self .redirecting = False
20042004
2005- def _cmd_func (self , command : str ) -> Optional [Callable ]:
2005+ def cmd_func (self , command : str ) -> Optional [Callable ]:
20062006 """
20072007 Get the function for a command
20082008 :param command: the name of the command
20092009 """
2010- func_name = self ._cmd_func_name (command )
2010+ func_name = self .cmd_func_name (command )
20112011 if func_name :
20122012 return getattr (self , func_name )
2013- return None
20142013
2015- def _cmd_func_name (self , command : str ) -> str :
2014+ def cmd_func_name (self , command : str ) -> str :
20162015 """Get the method name associated with a given command.
20172016
20182017 :param command: command to look up method name which implements it
@@ -2038,9 +2037,9 @@ def onecmd(self, statement: Union[Statement, str]) -> bool:
20382037 if statement .command in self .macros :
20392038 stop = self ._run_macro (statement )
20402039 else :
2041- cmd_func = self ._cmd_func (statement .command )
2042- if cmd_func :
2043- stop = cmd_func (statement )
2040+ func = self .cmd_func (statement .command )
2041+ if func :
2042+ stop = func (statement )
20442043
20452044 # Since we have a valid command store it in the history
20462045 if statement .command not in self .exclude_from_history :
@@ -2596,11 +2595,11 @@ def do_help(self, arglist: List[str]) -> None:
25962595 self ._help_menu (verbose )
25972596 else :
25982597 # Getting help for a specific command
2599- cmd_func = self ._cmd_func (arglist [0 ])
2600- if cmd_func :
2598+ func = self .cmd_func (arglist [0 ])
2599+ if func :
26012600 # Check to see if this function was decorated with an argparse ArgumentParser
2602- if hasattr (cmd_func , 'argparser' ):
2603- completer = AutoCompleter (getattr (cmd_func , 'argparser' ), cmd2_app = self )
2601+ if hasattr (func , 'argparser' ):
2602+ completer = AutoCompleter (getattr (func , 'argparser' ), cmd2_app = self )
26042603 self .poutput (completer .format_help (arglist ))
26052604 else :
26062605 # No special behavior needed, delegate to cmd base class do_help()
@@ -2623,12 +2622,12 @@ def _help_menu(self, verbose: bool=False) -> None:
26232622 cmds_cats = {}
26242623
26252624 for command in visible_commands :
2626- cmd_func = self ._cmd_func (command )
2627- if command in help_topics or cmd_func .__doc__ :
2625+ func = self .cmd_func (command )
2626+ if command in help_topics or func .__doc__ :
26282627 if command in help_topics :
26292628 help_topics .remove (command )
2630- if hasattr (cmd_func , HELP_CATEGORY ):
2631- category = getattr (cmd_func , HELP_CATEGORY )
2629+ if hasattr (func , HELP_CATEGORY ):
2630+ category = getattr (func , HELP_CATEGORY )
26322631 cmds_cats .setdefault (category , [])
26332632 cmds_cats [category ].append (command )
26342633 else :
@@ -2681,13 +2680,13 @@ def _print_topics(self, header: str, cmds: List[str], verbose: bool) -> None:
26812680 func = getattr (self , 'help_' + command )
26822681 except AttributeError :
26832682 # Couldn't find a help function
2684- cmd_func = self ._cmd_func (command )
2683+ func = self .cmd_func (command )
26852684 try :
26862685 # Now see if help_summary has been set
2687- doc = cmd_func .help_summary
2686+ doc = func .help_summary
26882687 except AttributeError :
26892688 # Last, try to directly access the function's doc-string
2690- doc = cmd_func .__doc__
2689+ doc = func .__doc__
26912690 else :
26922691 # we found the help function
26932692 result = io .StringIO ()
0 commit comments