How to use the typer.Argument function in typer

To help you get started, we’ve selected a few typer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tiangolo / typer / docs_src / arguments / help / tutorial004.py View on Github external
def main(name: str = typer.Argument("World", help="Who to greet", show_default=False)):
    """
    Say hi to NAME very gently, like Dirk.
    """
    typer.echo(f"Hello {name}")
github tiangolo / typer / docs_src / parameter_types / number / tutorial002.py View on Github external
def main(
    id: int = typer.Argument(..., min=0, max=1000),
    rank: int = typer.Option(0, max=10, clamp=True),
    score: float = typer.Option(0, min=0, max=100, clamp=True),
):
    typer.echo(f"ID is {id}")
    typer.echo(f"--rank is {rank}")
    typer.echo(f"--score is {score}")
github tiangolo / typer / docs_src / arguments / optional / tutorial002.py View on Github external
def main(name: Optional[str] = typer.Argument(None)):
    if name is None:
        typer.echo("Hello World!")
    else:
        typer.echo(f"Hello {name}")
github tiangolo / typer / docs_src / arguments / help / tutorial007.py View on Github external
def main(name: str = typer.Argument("World", hidden=True)):
    """
    Say hi to NAME very gently, like Dirk.
    """
    typer.echo(f"Hello {name}")
github tiangolo / typer / docs_src / arguments / optional / tutorial001.py View on Github external
def main(name: str = typer.Argument(...)):
    typer.echo(f"Hello {name}")
github tiangolo / typer / docs_src / arguments / default / tutorial002.py View on Github external
def main(name: str = typer.Argument(get_name)):
    typer.echo(f"Hello {name}")
github tiangolo / typer / docs_src / parameter_types / number / tutorial001.py View on Github external
def main(
    id: int = typer.Argument(..., min=0, max=1000),
    age: int = typer.Option(20, min=18),
    score: float = typer.Option(0, max=100),
):
    typer.echo(f"ID is {id}")
    typer.echo(f"--age is {age}")
    typer.echo(f"--score is {score}")
github tiangolo / typer / docs_src / arguments / help / tutorial006.py View on Github external
def main(name: str = typer.Argument("World", metavar="✨username✨")):
    typer.echo(f"Hello {name}")