-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Summary
It would be useful to end users of click CLI applications if when they misspelled CLI sub-commands they got a helpful Did you mean...
error message in a similar way to when they misspell an @option
name (e.g., --name
).
Motivating Example
Consider the following example Click CLI app:
import click
@click.group()
def cli():
pass
@cli.command()
@click.option("--name", "-n", default="World")
def greet(name: str) -> None:
click.echo(f"Hello, {name}")
@cli.command()
@click.option("--name", "-n", default="Friend")
def farewell(name: str) -> None:
click.echo(f"Goodbye, {name}")
if __name__ == "__main__":
cli()
If the user misspells --name
, they get a helpful Did you mean
error message:
$ ./main.py greet --nme David
Usage: main.py greet [OPTIONS]
Try 'main.py greet --help' for help.
Error: No such option: --nme Did you mean --name?
But if they misspell greet
, they do not:
$ ./main.py gret --name David
Usage: main.py [OPTIONS] COMMAND [ARGS]...
Try 'main.py --help' for help.
Error: No such command 'gret'.
Test Environment
- Click 8.3.0
- Python 3.13.8
Related Work
davidlengel
Metadata
Metadata
Assignees
Labels
No labels