Skip to content
Myr

parameters.md

This file

Path

docs/reference/parameters.md

31 lines 路 703 bytes 路 Markdown

Last changed by

Not known.

History of this file

Take it

Show the source

parameters.md

Parameters

Parameters to our command line interface may be both CLI Options and CLI Arguments:

from typing import Annotated
import typer

app = typer.Typer()

@app.command()
def register(
    user: Annotated[str, typer.Argument()],
    age: Annotated[int, typer.Option(min=18)],
    score: Annotated[float, typer.Option(max=100)] = 0,
):
    print(f"User is {user}")
    print(f"--age is {age}")
    print(f"--score is {score}")

if __name__ == "__main__":
    app()

::: typer.Argument options: show_overloads: false

::: typer.Option options: show_overloads: false