Skip to content

[QUESTION] why replace "_" with "-" in command name? #341

@bloodynumen

Description

@bloodynumen

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from typing import Optional

import typer

app = typer.Typer()


@app.command()
def hello_test(name: Optional[str] = None):
    if name:
        typer.echo(f"Hello {name}")
    else:
        typer.echo("Hello World!")

if __name__ == "__main__":
    app()

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions