Skip to content
Myr

use canonical command name instead of matched name

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ovezovs · committed by David Lord · parent f3e55b6 · Browse files · 3 files+21 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+21 added−1 removed

  • tests:+16 added−0 removed
  • other:+5 added−1 removed

3 files+21 added−1 removed

modified:src/click/core.py+1 added-1 removed
1344 unmodified lines
1345 if split_opt(cmd_name)[0]:1346 self.parse_args(ctx, ctx.args)1347 ctx.fail(f"No such command '{original_cmd_name}'.")13481349 return cmd_name, cmd, args[1:]1349 return cmd.name, cmd, args[1:]13501351 def get_command(self, ctx, cmd_name):1352 """Given a context and a command name, this returns a1353 :class:`Command` object if it exists or returns `None`.
726 unmodified lines
modified:tests/test_commands.py+16 added
256 unmodified lines
257 assert not result.exception258 assert result.output == "no subcommand, use default\nin subcommand\n"259260261def test_aliased_command_canonical_name(runner):262 class AliasedGroup(click.Group):263 def get_command(self, ctx, cmd_name):264 return push265266 cli = AliasedGroup()267268 @cli.command()269 def push():270 click.echo("push command")271272 result = runner.invoke(cli, ["pu", "--help"])273 assert not result.exception274 assert result.output.startswith("Usage: root push [OPTIONS]")275276277def test_unprocessed_options(runner):278 @click.command(context_settings=dict(ignore_unknown_options=True))279 @click.argument("args", nargs=-1, type=click.UNPROCESSED)280 @click.option("--verbose", "-v", count=True)
36 unmodified lines
modified:CHANGES.rst+4 added
22 unmodified lines
23- An option defined with duplicate flag names (``"--foo/--foo"``)24 raises a ``ValueError``. :issue:`1465`25- ``echo()`` will not fail when using pytest's ``capsys`` fixture on26 Windows. :issue:`1590`27- Resolving commands returns the canonical command name instead of the28 matched name. This makes behavior such as help text and29 ``Context.invoked_subcommand`` consistent when using patterns like30 ``AliasedGroup``. :issue:`1422`313233Version 7.1.234-------------
635 unmodified lines