-
-
Notifications
You must be signed in to change notification settings - Fork 778
📝 Clarify single-command vs multi-command behaviour in README #1268
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
📝 Clarify single-command vs multi-command behaviour in README #1268
Conversation
3eca414
to
4163446
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think I would personally move this note to after the part where python main.py hello Camila
and python main.py goodbye Camila
are executed - i.e. right before the section "recap". I would also try to make the note as short as possible, while referring to the more detailed section.
…ng. restore generated README.md
114718c
to
75b8db6
Compare
This comment was marked as outdated.
This comment was marked as outdated.
updated the PR based on @svlandeg’s feedback:
Let me know if you’d like me to tweak the formatting further! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. While I know we want to be mindful of keeping this page nice and short, I definitely can see how the difference between single and multi command usage is confusing, and a (relatively quick) note to address that seems like a good idea to me.
As always I'll defer to Tiangolo for the final decision though.
📝 Docs preview for commit ef31145 at: https://40a5e995.typertiangolo.pages.dev Modified Pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thanks @MorgenPronk! ☕
And thanks for the help @svlandeg and @YuriiMotov 🍰
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.