Skip to content
Discussion options

You must be logged in to vote

It's not documented, but yes, it works this way:

import typer

app = typer.Typer()

@app.command()
def my_command(
    arg1: str,
    opt1: str = "123",
):
    typer.echo(f"{arg1=}, {opt1=}")

if __name__ == "__main__":
    app()

Try it:

$ typer main.py run -qwerty
Usage: typer [PATH_OR_MODULE] run [OPTIONS] ARG1
Try 'typer [PATH_OR_MODULE] run --help' for help.
╭─ Error ───────────────────────────────────────────────────────────────────────────╮
│ No such option: -q                                                                │
╰───────────────────────────────────────────────────────────────────────────────────╯

$ typer main.py run -- -qwerty
arg1='-qwerty', opt1='123'

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants