Skip to content

Commit d173493

Browse files
committed
fix(argparse_completer): suppress completion hint for subcommands
Subcommands completion hint (often a list of subcommands) was being displayed above the prompt, which is redundant when prompt-toolkit displays the subcommands in the completion menu. This change suppresses the hint for _SubParsersAction, allowing the completion menu to be the primary guide for subcommands.
1 parent 68a7dc1 commit d173493

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cmd2/argparse_completer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ def update_mutex_groups(arg_action: argparse.Action) -> None:
460460

461461
# If we have results, then return them
462462
if completion_results:
463-
# Don't overwrite an existing hint
464-
if not self._cmd2_app.completion_hint:
463+
# Don't overwrite an existing hint or show a hint for subcommands
464+
if not self._cmd2_app.completion_hint and not isinstance(pos_arg_state.action, argparse._SubParsersAction):
465465
self._cmd2_app.completion_hint = _build_hint(self._parser, pos_arg_state.action)
466466
return completion_results
467467

0 commit comments

Comments
 (0)