Custom Command Name

By default, the command names are generated from the function name.

So, if your function is something like:

def create(username: str):

Then the command name will be create.

But if you already had a function called create() somewhere in your code, you would have to name your CLI function differently.

And what if you wanted the command to still be named create?

For this, you can set the name of the command in the first parameter for the @app.command() decorator:

import typer

app = typer.Typer()

def cli_create_user(username: str):
    print(f"Creating user: {username}")

def cli_delete_user(username: str):
    print(f"Deleting user: {username}")

if __name__ == "__main__":

Now, even though the functions are named cli_create_user() and cli_delete_user(), the commands will still be named create and delete:

$ python --help


  --install-completion  Install completion for the current shell.
  --show-completion     Show completion for the current shell, to copy it or customize the installation.
  --help                Show this message and exit.


// Test it
$ python create Camila

Creating user: Camila
You can ask questions about Typer. Try:
How can I terminate a program?
How to launch applications?
How to add help to CLI argument?