Skip to content
Myr

complete commands using registered names

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

authored by Jan Kowalleck · committed by David Lord · parent de75b40 · Browse files · 3 files+15 added−6 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+15 added−6 removed

  • tests:+7 added−0 removed
  • other:+8 added−6 removed

3 files+15 added−6 removed

modified:src/click/core.py+6 added-6 removed
68 unmodified lines
69 if name.startswith(incomplete):70 command = ctx.command.get_command(ctx, name)7172 if not command.hidden:73 yield command73 yield name, command747576def _check_multicommand(base_command, cmd_name, cmd, register=False):77 if not base_command.chain or not isinstance(cmd, MultiCommand):
806 unmodified lines
884 ctx = ctx.parent885886 if isinstance(ctx.command, MultiCommand) and ctx.command.chain:887 results.extend(888 ("plain", command.name, command.get_short_help_str())889 for command in _complete_visible_commands(ctx, incomplete)890 if command.name not in ctx.protected_args888 ("plain", name, command.get_short_help_str())889 for name, command in _complete_visible_commands(ctx, incomplete)890 if name not in ctx.protected_args891 )892893 return results894
694 unmodified lines
15891590 .. versionadded:: 8.01591 """1592 results = [1593 ("plain", command.name, command.get_short_help_str())1594 for command in _complete_visible_commands(ctx, incomplete)1593 ("plain", name, command.get_short_help_str())1594 for name, command in _complete_visible_commands(ctx, incomplete)1595 ]1596 results.extend(super().shell_complete(ctx, args, incomplete))1597 return results1598
856 unmodified lines
modified:tests/test_shell_completion.py+7 added
201 unmodified lines
202 assert _get_words(cli, ["hidden"], "-") == ["-a"]203 assert _get_words(cli, ["hidden", "-b"], "") == ["a", "b"]204205206def test_add_different_name():207 cli = Group("cli", commands={"renamed": Command("original")})208 words = _get_words(cli, [], "")209 assert "renamed" in words210 assert "original" not in words211212213@pytest.fixture()214def _patch_for_completion(monkeypatch):215 monkeypatch.setattr("click.core._fast_exit", sys.exit)216 monkeypatch.setattr(
31 unmodified lines
modified:CHANGES.rst+2 added
94 unmodified lines
95 - Support Bash >= 4.4, Zsh, and Fish, with the ability for96 extensions to add support for other shells.97 - Allow commands, groups, parameters, and types to override their98 completions suggestions.99 - Groups complete the names commands were registered with, which100 can differ from the name they were created with.101102103Version 7.1.2104-------------
635 unmodified lines