Skip to content

Conversation

savannahostrowski
Copy link
Member

This PR adds a common CLI feature as optional to Typer (i.e. off by default), allowing users to enable command suggestions for typos (similar to the recently added suggest_on_error feature in argparse) without any additional dependency.

Usage

import typer

app = typer.Typer(suggest_commands=True)

@app.command()
def create():
    typer.echo("Creating...")

@app.command()
def delete():
    typer.echo("Deleting...")

if __name__ == "__main__":
    app()

If a user were to type crate instead of create, they would then see an error message like so:

Error: No such command 'crate'. Did you mean 'create'?

@savannahostrowski savannahostrowski added the feature New feature, enhancement or request label Oct 8, 2025
Copy link
Contributor

github-actions bot commented Oct 8, 2025

@svlandeg svlandeg self-assigned this Oct 9, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great feature to have, and I would have even wanted to enable this by default. But to minimize unexpected impact on users it probably makes sense to have it disabled by default as you suggest.

Love all the tests, went through it all and all looked good. Addition to the tutorial is perfect and the added code is minimal and clean.

Could really only find the smallest of nitpicks, but happy to approve either way. 😉

@svlandeg svlandeg removed their assignment Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature, enhancement or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants