Extends click.Group to invoke a command without explicit subcommand name
Project description
Click Default Group
DefaultGroup
is a sub class of click.Group
. But it invokes a default
subcommand instead of showing a help message when a subcommand is not passed.
Usage
Define a default subcommand by default=NAME
:
import click
from click_default_group import DefaultGroup
@click.group(cls=DefaultGroup, default='foo', default_if_no_args=True)
def cli():
pass
@cli.command()
def foo():
click.echo('foo')
@cli.command()
def bar():
click.echo('bar')
Then you can invoke that without explicit subcommand name:
$ cli.py --help
Usage: cli.py [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Command:
foo*
bar
$ cli.py
foo
$ cli.py foo
foo
$ cli.py bar
bar
Compatibility
click-default-group
is compatible with these Click versions:
- Click-7.0
- Click-6.x
- Click-5.1
- Click-5.0
- Click-4.1
- Click-4.0
See the latest build status at Travis CI.
Licensing
Written by Heungsub Lee, and distributed under the BSD 3-Clause license.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file click-default-group-1.2.2.tar.gz
.
File metadata
- Download URL: click-default-group-1.2.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9560e8e8dfa44b3562fbc9425042a0fd6d21956fcc2db0077f63f34253ab904 |
|
MD5 | 4f0f38b1105d032a19f24c2661b0a82a |
|
BLAKE2b-256 | 223ae9feb3435bd4b002d183fcb9ee08fb369a7e570831ab1407bc73f079948f |