Skip to content
Myr

:sparkles: Add first version of subcommands tutorial

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by Sebastián Ramírez · parent d12d00e · Browse files · 4 files+49 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+49 added−0 removed

  • other:+49 added−0 removed

4 files+49 added−0 removed

added:docs/src/subcommands/tutorial001/app/__init__.py
added:docs/src/subcommands/tutorial001/app/items.py+22 added
1import typer23app = typer.Typer()456@app.command()7def create(item: str):8 typer.echo(f"Creating item: {item}")91011@app.command()12def delete(item: str):13 typer.echo(f"Deleting item: {item}")141516@app.command()17def sell(item: str):18 typer.echo(f"Selling item: {item}")192021if __name__ == "__main__":22 app()
added:docs/src/subcommands/tutorial001/app/main.py+10 added
1import typer23from . import items, users45app = typer.Typer()6app.add_typer(users.app, name="users")7app.add_typer(items.app, name="items")89if __name__ == "__main__":10 app()
added:docs/src/subcommands/tutorial001/app/users.py+17 added
1import typer23app = typer.Typer()456@app.command()7def create(user_name: str):8 typer.echo(f"Creating user: {user_name}")91011@app.command()12def delete(user_name: str):13 typer.echo(f"Deleting user: {user_name}")141516if __name__ == "__main__":17 app()