From 7938d89d5e25ff02732cac5aa5bc7fd7d03591bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 4 Jan 2020 01:51:44 +0100 Subject: [PATCH] :sparkles: Add first version of subcommands tutorial --- .../subcommands/tutorial001/app/__init__.py | 0 docs/src/subcommands/tutorial001/app/items.py | 22 +++++++++++++++++++ docs/src/subcommands/tutorial001/app/main.py | 10 +++++++++ docs/src/subcommands/tutorial001/app/users.py | 17 ++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 docs/src/subcommands/tutorial001/app/__init__.py create mode 100644 docs/src/subcommands/tutorial001/app/items.py create mode 100644 docs/src/subcommands/tutorial001/app/main.py create mode 100644 docs/src/subcommands/tutorial001/app/users.py diff --git a/docs/src/subcommands/tutorial001/app/__init__.py b/docs/src/subcommands/tutorial001/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/docs/src/subcommands/tutorial001/app/items.py b/docs/src/subcommands/tutorial001/app/items.py new file mode 100644 index 0000000..608880b --- /dev/null +++ b/docs/src/subcommands/tutorial001/app/items.py @@ -0,0 +1,22 @@ +import typer + +app = typer.Typer() + + +@app.command() +def create(item: str): + typer.echo(f"Creating item: {item}") + + +@app.command() +def delete(item: str): + typer.echo(f"Deleting item: {item}") + + +@app.command() +def sell(item: str): + typer.echo(f"Selling item: {item}") + + +if __name__ == "__main__": + app() diff --git a/docs/src/subcommands/tutorial001/app/main.py b/docs/src/subcommands/tutorial001/app/main.py new file mode 100644 index 0000000..5f0d8a8 --- /dev/null +++ b/docs/src/subcommands/tutorial001/app/main.py @@ -0,0 +1,10 @@ +import typer + +from . import items, users + +app = typer.Typer() +app.add_typer(users.app, name="users") +app.add_typer(items.app, name="items") + +if __name__ == "__main__": + app() diff --git a/docs/src/subcommands/tutorial001/app/users.py b/docs/src/subcommands/tutorial001/app/users.py new file mode 100644 index 0000000..49315e1 --- /dev/null +++ b/docs/src/subcommands/tutorial001/app/users.py @@ -0,0 +1,17 @@ +import typer + +app = typer.Typer() + + +@app.command() +def create(user_name: str): + typer.echo(f"Creating user: {user_name}") + + +@app.command() +def delete(user_name: str): + typer.echo(f"Deleting user: {user_name}") + + +if __name__ == "__main__": + app()