📝 Clarify single-command vs multi-command behaviour in README #1268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a note in the README explaining that Typer treats single-command CLIs differently than multi-command CLIs.
This behavior can be surprising for new users (like myself), because calling the command by name (e.g., python cli.py hello Camila) results in an error when only one command is defined — Typer silently expects python cli.py Camila instead.
While this is explained in the full documentation, the README contains a similar example and is often the first place beginners look. A brief clarification here could help save users some confusion — especially those coming from FastAPI, where the number of wrapped functions doesn’t affect how the app is invoked.
Related issues:
#315 - this PR directly addresses confusion raised here.
#445 - is tangentially related in that it also highlights behavioral differences when only one subcommand exists.
I’ve also explored making this behavior configurable (i.e., supporting both styles of invocation), and I’d be happy to help further if there’s interest. But this change is a simple, non-breaking way to surface the existing behavior earlier for new users.
Let me know if you'd prefer the note be placed elsewhere, want to reword it, or would like help drafting a fuller fix later on.