Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
633589f
✨ Enhance command alias handling and display in Typer
pipinstalled Nov 23, 2025
bd594d3
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Nov 23, 2025
963c14b
fix some tests error
pipinstalled Nov 23, 2025
d6f8c0c
Merge branch 'feature/CommandAliases' of github.com:pipinstalled/type…
pipinstalled Nov 23, 2025
d7bf3f8
fix coverage test failed
pipinstalled Nov 24, 2025
80e2c1d
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2025
db5d273
Add test for multiple command aliases in
pipinstalled Nov 24, 2025
72eb6d9
Merge branch 'feature/CommandAliases' of github.com:pipinstalled/type…
pipinstalled Nov 24, 2025
82eedc9
Add tests for command list deduplication and comprehensive coverage
pipinstalled Nov 24, 2025
ba0322c
Add tests for command visibility and alias functionality
pipinstalled Nov 24, 2025
d79df74
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2025
dedad51
Merge branch 'master' into feature/CommandAliases
svlandeg Nov 25, 2025
8bce656
📝 Add coverage pragma to command alias test functions
pipinstalled Nov 25, 2025
e214089
📝 Add test for command list deduplication with aliases
pipinstalled Nov 25, 2025
09f893d
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2025
47fc8e6
📝 Add tests for command formatting with and without aliases when rich…
pipinstalled Nov 26, 2025
0db6305
Merge branch 'feature/CommandAliases' of github.com:pipinstalled/type…
pipinstalled Nov 26, 2025
b0db5dc
📝 Add additional tests for command formatting and help output when ri…
pipinstalled Nov 26, 2025
fb96046
Merge branch 'master' into feature/CommandAliases
pipinstalled Nov 26, 2025
751677e
resolve the conflict with main branch
pipinstalled Dec 25, 2025
f77f2a7
Merge branch 'feature/CommandAliases' of github.com:pipinstalled/type…
pipinstalled Dec 25, 2025
783bb6b
Merge branch 'master' into feature/CommandAliases
pipinstalled Dec 25, 2025
490d2ab
📝 Update command alias tests to improve coverage and ensure consisten…
pipinstalled Dec 25, 2025
7d6c004
Merge branch 'feature/CommandAliases' of github.com:pipinstalled/type…
pipinstalled Dec 25, 2025
baed5c3
🎨 Auto format
pre-commit-ci-lite[bot] Dec 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions docs/tutorial/commands/name.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,91 @@ def create_user(username: str):
...
```
Then the command name will be `create-user`.

## Command Aliases

You can define aliases for commands so users can call them with different names.

### Positional Aliases

Pass additional positional arguments to `@app.command()`:

{* docs_src/commands/name/tutorial002.py hl[6,9] *}

The `list` command can be called with `list` or `ls`:

<div class="termy">

```console
$ python main.py --help

Usage: main.py [OPTIONS] COMMAND [ARGS]...

Options:
--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.

Commands:
list, ls
remove, rm, delete

$ python main.py list

Listing items

$ python main.py ls

Listing items

$ python main.py remove

Removing items

$ python main.py rm

Removing items

$ python main.py delete

Removing items
```

</div>

### Keyword Aliases

Use the `aliases` parameter:

{* docs_src/commands/name/tutorial002.py hl[9] *}

Positional aliases and the `aliases` parameter can be combined.

### Hidden Aliases

Use `hidden_aliases` for aliases that work but don't appear in help:

{* docs_src/commands/name/tutorial003.py hl[6] *}

<div class="termy">

```console
$ python main.py --help

Usage: main.py [OPTIONS] COMMAND [ARGS]...

Options:
--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.

Commands:
list, ls
remove

$ python main.py secretlist

Listing items
```

</div>
17 changes: 17 additions & 0 deletions docs_src/commands/name/tutorial002.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import typer

app = typer.Typer()


@app.command("list", "ls")
def list_items():
print("Listing items")


@app.command("remove", aliases=["rm", "delete"])
def remove_items():
print("Removing items")


if __name__ == "__main__":
app()
17 changes: 17 additions & 0 deletions docs_src/commands/name/tutorial003.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import typer

app = typer.Typer()


@app.command("list", "ls", hidden_aliases=["secretlist"])
def list_items():
print("Listing items")


@app.command("remove")
def remove_items():
print("Removing items")


if __name__ == "__main__":
app()
Loading