Chained command with argument and option results in "No such command"
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.7k
- Forks
- 2.3k
- Avg merge
- 1d 30m
- Merged PRs (30d)
- 18
Description
Chained command with argument and option results in "No such command"; according to the documentation,
Other than that [
nargs=-1being allowed only on the last chained command] there are no restrictions on how they [chained commands] work. They can accept options and arguments as normal.
Reproduced on Ubuntu 18.04 with Python 3.5, 3.6 and 3.7, for all tagged Click versions between 3.0 and 7.0 (chain= does not seem to be supported for the ones before that).
Minimal repro (removing the argument allows the option to be recognized):
import click
@click.group(chain=True, no_args_is_help=False)
def cli():
pass
@cli.command()
@click.argument('argument')
@click.option('--option')
def command(argument, option):
pass
if __name__ == '__main__':
cli()
Results in:
$ python3 test.py command a --option x
Usage: test.py [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]...
Try "test.py --help" for help.
Error: No such command "--option".
$ python3 test.py command --help
Usage: test.py command [OPTIONS] ARGUMENT
Options:
--option TEXT
--help Show this message and exit.
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
Run the minimal Python reproduction from the issue with a chained Click command, both with and without the argument. Trace the chained-command argument parsing entry point and add or update the relevant regression coverage; done means an option after a command argument is recognized instead of reported as a command.
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
- 45/100