Registry / devops / click-didyoumean

click-didyoumean

JSON →
library0.3.1pypypi✓ verified 26d ago

This library enables a 'did-you-mean' suggestion feature, similar to Git, for Click-based command-line interfaces. It provides an extended `Group` and `CommandCollection` class to automatically suggest correct commands for mistyped inputs. It is currently at version 0.3.1 and is infrequently updated.

pip install click-didyoumean
INSTALL
IMPORT
SIG · CLICK-DIDYOUMEAN
C
click-didyoumean
devopspythonv0.3.1
Install
1.6s avg
Import
87ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.098s · 18.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.076s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DYMGroup
from click_didyoumean import DYMGroup
Use this to add 'did-you-mean' functionality to a single Click group.
DYMCommandCollection
from click_didyoumean import DYMCommandCollection
Use this for CLIs composed of multiple Click group sources (CommandCollection).

To enable the 'did-you-mean' feature, simply pass `cls=DYMGroup` to your `click.group` decorator. For more complex applications using `CommandCollection`, substitute `DYMCommandCollection`.

import click from click_didyoumean import DYMGroup @click.group(cls=DYMGroup) # Apply DYMGroup as the class for your main CLI group def cli(): """A simple CLI with did-you-mean suggestions.""" pass @cli.command() def deploy(): """Deploys the application.""" click.echo("Deploying application...") @cli.command() def delete(): """Deletes resources.""" click.echo("Deleting resources...") @cli.command() def devops(): """Runs devops tasks.""" click.echo("Running devops tasks...") if __name__ == '__main__': # Example usage (run from terminal, e.g., `python your_cli.py deplo`) will suggest `deploy` cli()
Debug
Known issues
gotchaWhen combining multiple Click group sources, you must use `DYMCommandCollection` instead of `DYMGroup`.
fix
Instead of decorating a group, create an instance of `DYMCommandCollection` and pass your existing `click.Group` objects as `sources`. Example: `cli = DYMCommandCollection(sources=[cli1, cli2])`.
affects: All versions
gotchaThe default number of suggestions (max_suggestions) and similarity cutoff (cutoff) might not be ideal for all applications.
fix
You can configure `max_suggestions` (default 3) and `cutoff` (default 0.5) when initializing `DYMGroup` or `DYMCommandCollection` to fine-tune the suggestion behavior. For example: `@click.group(cls=DYMGroup, max_suggestions=5, cutoff=0.7)`.
affects: All versions
gotchaThe library relies on Click's internal group and command handling. Major updates to Click could potentially introduce breaking changes in how these extensions integrate.
fix
Always test `click-didyoumean` functionality after upgrading `Click` to a new major version. Keep `click-didyoumean` updated to its latest release.
affects: Potentially future major Click versions (e.g., Click 9.x+)
gotchaThe library officially supports Python 3.8 and above, as indicated in its `pyproject.toml`.
fix
Ensure your project uses Python 3.8 or newer. While older PyPI metadata might suggest Python >=3.6.2, the current development points to 3.8+.
affects: <3.8
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'click_didyoumean'
The 'click-didyoumean' package has not been installed in your Python environment, or your Python interpreter cannot find it.
fix
Install the package using pip: `pip install click-didyoumean`
ModuleNotFoundError: No module named 'click'
The 'click' library, which 'click-didyoumean' depends on, is not installed or cannot be found by your Python environment.
fix
Install the 'click' package: `pip install click` (This is usually installed automatically with `click-didyoumean`, but might be missing in some specific setups or if `click` was uninstalled separately).
Error: No such command 'mistyped_command'.
This Click error appears when a command is misspelled and 'click-didyoumean' has not been correctly integrated into your Click application (e.g., by forgetting to use `cls=DYMGroup` or `DYMCommandCollection`). The library's purpose is to add 'Did you mean?' suggestions to this specific error message.
fix
Ensure your Click group uses the `DYMGroup` class: `@click.group(cls=DYMGroup)` or that you are using `DYMCommandCollection` correctly for collections. Make sure you have imported `DYMGroup` or `DYMCommandCollection` from `click_didyoumean`.
Upgrade
Version history
0.3.1latest on PyPI · released Mar 24, 2024
Audit
Dependencies
clickrequiredCore dependency for building command-line interfaces, which this library extends. Requires click>=7.
Agent activity
16 hits · last 30 days
node
14
Resources
click-didyoumean — pip install click-didyoumean · libregistry