Closed ghost closed 6 years ago
Hi I'm looking for a way to use click-default-group while providing a cli --version option to get the cli version. Is there a way to get cli --version to print cli 0.0.1?
click-default-group
cli --version
cli 0.0.1
import click from click_default_group import DefaultGroup VERSION = 'cli 0.0.1' @click.group(cls=DefaultGroup, default='foo', default_if_no_args=True) @click.option('--version', is_flag=True, default=False) def cli(version): click.echo(VERSION) @cli.command() def foo(): click.echo('foo') @cli.command() def bar(): click.echo('bar') @cli.command('--version') def cli_version(): click.echo(VERSION) cli()
$ python cli.py --version Usage: cli.py [OPTIONS] COMMAND [ARGS]... Error: Missing command.
invoke_without_command=True in
invoke_without_command=True
@click.group(cls=DefaultGroup, default='foo', default_if_no_args=True, invoke_without_command=True)
does the trick.
Hi I'm looking for a way to use
click-default-group
while providing acli --version
option to get the cli version. Is there a way to getcli --version
to printcli 0.0.1
?