Skip to content

Commit 9a7818b

Browse files
committed
Fixed issue where invalid subcommand token was ignored when retrieving help text
1 parent 65ed685 commit 9a7818b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd2/argparse_completer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,16 +424,17 @@ def format_help(self, tokens: List[str]) -> str:
424424
"""
425425
Supports cmd2's help command in the retrieval of help text
426426
:param tokens: command line tokens
427-
:return: help text of the commmand being queried
427+
:return: help text of the command being queried
428428
"""
429-
# If our parser has subcommands, we must examine the tokens and check if any reference one.
429+
# If our parser has subcommands, we must examine the tokens and check if they are subcommands
430430
# If so, we will let the subcommand's parser handle the rest of the tokens via another AutoCompleter.
431431
if self._subcommand_action is not None:
432432
for token_index, token in enumerate(tokens[1:], start=1):
433433
if token in self._subcommand_action.choices:
434434
completer = AutoCompleter(self._subcommand_action.choices[token], self._cmd2_app)
435435
return completer.format_help(tokens[token_index:])
436-
436+
else:
437+
break
437438
return self._parser.format_help()
438439

439440
def _complete_for_arg(self, arg_action: argparse.Action,

0 commit comments

Comments
 (0)