Skip to content
Myr

:recycle: Refactor subcommands to not require being a package

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 7938d89 · Browse files · 7 files+50 added−49 removed
This commit

State

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

Diff stats

7 files+50 added−49 removed

  • other:+50 added−49 removed

7 files+50 added−49 removed

deleted:docs/src/subcommands/tutorial001/app/__init__.py
deleted:docs/src/subcommands/tutorial001/app/items.py-22 removed
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()
deleted:docs/src/subcommands/tutorial001/app/main.py-10 removed
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()
deleted:docs/src/subcommands/tutorial001/app/users.py-17 removed
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()
added:docs/src/subcommands/tutorial001/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/main.py+11 added
1import typer23import items4import users56app = typer.Typer()7app.add_typer(users.app, name="users")8app.add_typer(items.app, name="items")910if __name__ == "__main__":11 app()
added:docs/src/subcommands/tutorial001/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()