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-didyoumeanVerified import paths — ran on the pinned version, not inferred.
To enable the 'did-you-mean' feature, simply pass `cls=DYMGroup` to your `click.group` decorator. For more complex applications using `CommandCollection`, substitute `DYMCommandCollection`.
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])`.
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)`.
Always test `click-didyoumean` functionality after upgrading `Click` to a new major version. Keep `click-didyoumean` updated to its latest release.
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+.
Install the package using pip: `pip install click-didyoumean`
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).
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`.