Calmcode - typer: commands

Adding Commands in Typer

1 2 3 4 5 6 7 8 9 10

Just like a python library usually has multiple functions a command line app usually has multiple commands. So let's make a typer command line application that can handle multiple actions.

import typer

app = typer.Typer(name="demo", add_completion=False, help="This is a demo app.")

def hello_world(name):
    """Say hello"""
    print(f"hello {name}!")

def goodbye_world(name):
    """Say goodbye"""
    print(f"goodbye {name}!")

if __name__ == "__main__":

You should now be able to run the following commands;

python --help
python hello-world vincent
python goodbye-world vincent