Enables git-like *did-you-mean* feature in click
Project description
Enable git-like did-you-mean feature in click.
It’s as simple as this:
import click
from click_didyoumean import DYMGroup
@click.group(cls=DYMGroup)
def cli():
...
Usage
Install this extension with pip:
pip install click-didyoumean
Use specific did-you-mean group class for your cli:
import click
from click_didyoumean import DYMGroup
@click.group(cls=DYMGroup)
def cli():
pass
@cli.command()
def foo():
pass
@cli.command()
def bar():
pass
@cli.command()
def barrr():
pass
if __name__ == "__main__":
cli()
Or you it in a CommandCollection:
import click
from click_didyoumean import DYMCommandCollection
@click.group()
def cli1():
pass
@cli1.command()
def foo():
pass
@cli1.command()
def bar():
pass
@click.group()
def cli2():
pass
@cli2.command()
def barrr():
pass
cli = DYMCommandCollection(sources=[cli1, cli2])
if __name__ == "__main__":
cli()
Change configuration
There are two configuration for the DYMGroup and DYMCommandCollection:
Parameter |
Type |
Default |
Description |
---|---|---|---|
max_suggestions |
int |
3 |
Maximal number of did-you-mean suggestions |
cutoff |
float |
0.5 |
Possibilities that don’t score at least that similar to word are ignored. |
Examples
@cli.group(cls=DYMGroup, max_suggestions=2, cutoff=0.7)
def cli():
pass
... or ...
cli = DYMCommandCollection(sources=[cli1, cli2], max_suggestions=2, cutoff=0.7)
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
Built Distribution
File details
Details for the file click_didyoumean-0.3.1.tar.gz
.
File metadata
- Download URL: click_didyoumean-0.3.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f82fdff0dbe64ef8ab2279bd6aa3f6a99c3b28c05aa09cbfc07c9d7fbb5a463 |
|
MD5 | a7d95362366d8e8db0f6f5432dcc0279 |
|
BLAKE2b-256 | 30ce217289b77c590ea1e7c24242d9ddd6e249e52c795ff10fac2c50062c48cb |
File details
Details for the file click_didyoumean-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: click_didyoumean-0.3.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c4bb6007cfea5f2fd6583a2fb6701a22a41eb98957e63d0fac41c10e7c3117c |
|
MD5 | be5e8cf5f80862c7e82e998f648c853a |
|
BLAKE2b-256 | 1b5b974430b5ffdb7a4f1941d13d83c64a0395114503cc357c6b9ae4ce5047ed |