click-didyoumean

0.3.1 · active · verified Sat Mar 28

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.

Warnings

Install

Imports

Quickstart

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()

view raw JSON →