Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide suggestions for misspelled subcommands #2764

Open
dionhaefner opened this issue Aug 12, 2024 · 0 comments
Open

Provide suggestions for misspelled subcommands #2764

dionhaefner opened this issue Aug 12, 2024 · 0 comments

Comments

@dionhaefner
Copy link

Example app:

import click

@click.group()
def cli():
    pass

@cli.command()
@click.option("--name", default="World", help="Name of the person to greet.")
def hello(name):
    click.echo(f"Hello, {name}!")

@cli.command()
def goodbye():
    click.echo("Goodbye!")

if __name__ == "__main__":
    cli()

Providing suggestions works well for options:

$ python clickfoo.py hello --namee
Usage: clickfoo.py hello [OPTIONS]
Try 'clickfoo.py hello --help' for help.

Error: No such option: --namee Did you mean --name?

But not for subcommands:

$ python clickfoo.py hellow
Usage: clickfoo.py [OPTIONS] COMMAND [ARGS]...
Try 'clickfoo.py --help' for help.

Error: No such command 'hellow'.

Desired output:

$ python clickfoo.py hellow
Usage: clickfoo.py [OPTIONS] COMMAND [ARGS]...
Try 'clickfoo.py --help' for help.

Error: No such command 'hellow'. Did you mean `hello`?

Is this something that can be done with click?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant