typer-cli
typer-cli copied to clipboard
Support extended type definition for more explicit semantics.
from typing import Optional
import typer
app = typer.Typer()
@app.command()
def hello(name: str= ''):
if name:
typer.echo(f"Hello {name}")
else:
typer.echo("Hello World!")
Extending the typing may help understanding the semantics, which make it more explicit. It can establish a strong connection between func arguments and CLI arguments? And make it less "magic".
Like:
@app.command()
def hello(name: cli_str= ''):
if name:
typer.echo(f"Hello {name}")
else:
typer.echo("Hello World!")
Personal opinion, welcome for discussion~