1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
Click Default Group
===================
`DefaultGroup` is a subclass of
[`click.Group`](https://click.pocoo.org/6/api/#click.Group). But it invokes
the default subcommand instead of showing a help message when a subcommand is
not passed.
[]
Usage
-----
Define a default subcommand by `default=NAME`:
```python
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:
```console
$ 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-8.x
- Click-7.x
- Click-6.x
- Click-5.x
- Click-4.x
Licensing
---------
Written by [Heungsub Lee], and distributed under the [BSD 3-Clause] license.
[Heungsub Lee]: https://subl.ee/
[BSD 3-Clause]: https://opensource.org/licenses/BSD-3-Clause
|