-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
f:chainfeature: chained commandsfeature: chained commands
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.
Metadata
Metadata
Assignees
Labels
f:chainfeature: chained commandsfeature: chained commands