Subcommands prefixed with a forward slash are seemingly ignored
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
I don't actually have any clue what's going on here, but I've tracked the misbehavior down to a specific commit, with a failing test fails on this commit, but succeeds on the previous commit.
Let's start with the test case:
def test_bad_command(runner):
@click.group()
def cli():
pass
@cli.command()
def wups():
pass
result = runner.invoke(cli, ['other'])
assert 'No such command' in result.output
result = runner.invoke(cli, ['/other'])
assert 'No such command' in result.output
This probably explains the issue better. In normal situations, we'd expect some call to cli other to come back and error with "No such command ...", but in the case if prefixing with a forward slash, it somehow tricks the parser into ignoring the entire argument and instead, we get the help of the parent command.
This behavior seems to be broken starting with commit 0a2919f34fcbc635d8530b4c5b60bf119b2bcedb, and the tests fail when applied here, but pass when applied against e68766c35ab134af2db2abf7cbd6f31e9b25d150.
Let me know if there's more information I can provide to help find the issue.
To add to it, in terms of releases, this means the behavior worked against Click 5.1, but has failed since Click 6.0 and continues to not work through latest master.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided test_bad_command case with Click's CLI runner, comparing behavior around commits 0a2919f34fcbc635d8530b4c5b60bf119b2bcedb and e68766c35ab134af2db2abf7cbd6f31e9b25d150. Trace how the CLI parser handles the /other argument. Done means both other and /other produce a No such command error instead of showing the parent command's help.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100