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
[QUESTION] why replace "_" with "-" in command name? #341
Comments
This is probably just a design choice based around natural CLI convention. You're usually gonna find dashes in commands in any CLI, not underscores. If you want to keep the underscore, you can just specify the command name manually in the app.command(). |
This type of undocumented behavior is why I have decided not to use Typer. I like a lot of things about the package, but it's not worth the learning curve of digging through the code when something doesn't work as expected. |
I guess that helps |
In fact, this is something that comes from the "click" package which typer uses as a base. If it helps, it comes from here: |
Yeah this is pretty annoying. Is there any way to disable this behaviour? There doesn't seem to be anything in |
I don’t think so, since it comes from click. I switched to Python Fire by google. |
Ok this comes from You can fix it like this:
I suggest an annotation on Also note for |
Ah I hadn't heard of that. Had a look but it seems like it has a slightly different focus and also doesn't support type hints which is like 90% of the reason for using Typer. I'll stick with my |
Hmm interesting. Can you check if it also works for option names? I mean like --cool_option gets transformed into cool-option? Thanks :) |
Yep that's how I'm using it.
|
Thanks, you saved me a lot of time! |
First Check
Commit to Help
Example Code
Description
expect:
python main.py hello_test --name world
actually:
python main.py hello-test --name world
I found the "_" in command name is replaced with "-".
source code https://github.com/tiangolo/typer/blob/master/typer/main.py#L390
why do this?
Thank u
Operating System
macOS
Operating System Details
No response
Typer Version
0.4.0
Python Version
3.9.7
Additional Context
No response
The text was updated successfully, but these errors were encountered: