Skip to content

fix(commands): support unquoted subcommands in help command (#258) - #545

Open
DYNOSuprovo wants to merge 1 commit into
python-poetry:mainfrom
DYNOSuprovo:fix/help-nested-subcommands-258
Open

DYNOSuprovo wants to merge 1 commit into
python-poetry:mainfrom
DYNOSuprovo:fix/help-nested-subcommands-258

Conversation

@DYNOSuprovo

Copy link
Copy Markdown

Fixes #258

Description

Currently, running <app> help <subcommand> <action> (such as poetry help env use) fails with The command "env" does not exist unless the subcommand arguments are quoted (e.g. poetry help "env use").

This happens because HelpCommand defined command_name with is_list=False. When multiple subcommand tokens are passed, ArgvInput assigns only the first token to command_name and ignores subsequent tokens due to ignore_validation_errors(), causing Application.find() to fail to resolve the command.

Changes

  • Updated HelpCommand.arguments to define command_name with is_list=True and default=["help"].
  • In HelpCommand.handle(), join command_name tokens with spaces if a list is received before finding the command in the application.
  • Updated application_run5.txt fixture to match the updated synopsis formatting for list arguments ([<command_name>...] and default: ["help"]).
  • Added unit test test_run_help_with_nested_subcommand in tests/test_application.py asserting that unquoted subcommand help (help foo bar baz and --help foo bar baz) resolves correctly and matches quoted help (help "foo bar baz").
  • Added towncrier news entry news/258.bugfix.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quotes required to use the built-in help command with a nested subcommand

1 participant