typer-alias is a lightweight extension for Typer that adds first-class command aliases while keeping the help output clean and user-friendly. Define a command once, expose it under multiple names, and display aliases directly in the CLI help.
Project description
typer-alias
Add command aliases to your Typer CLI with clean, readable help output.
typer-alias is a tiny utility that extends
Typer by allowing a command to have one or
more aliases while keeping the generated help concise.
Instead of registering multiple command implementations, write your command once and expose it under multiple names.
Features
- ✅ Simple decorator API
- ✅ Support for unlimited aliases
- ✅ Aliases actually work as independent commands
- ✅ Clean help output
- ✅ Zero runtime dependencies besides Typer
Installation
pip install typer-alias
Quick Start
import typer
from typer_alias import command
app = typer.Typer()
@command(
app,
name="list",
aliases=("ls", "l"),
)
def get_all():
"""Get all users."""
print("Getting users...")
if __name__ == "__main__":
app()
All of the following commands execute the same function:
app list
app ls
app l
Help Output
Instead of listing every alias as a separate command, the help is displayed as:
Commands:
list (ls, l) Get all users.
This keeps the help page compact while still showing users every available alias.
API
command(...)
A drop-in replacement for @app.command.
command(
app,
*,
name=None,
aliases=None,
help=None,
hidden=False,
...
)
Parameters
| Parameter | Description |
|---|---|
app |
The typer.Typer application. |
name |
Override the command name. Defaults to the function name. |
aliases |
Iterable of alternative command names. |
help |
Command help text. |
hidden |
Hide the command from help output. |
cls |
Custom TyperCommand class. |
context_settings |
Click context settings. |
epilog |
Help epilog. |
options_metavar |
Override options metavar. |
add_help_option |
Enable/disable --help. |
no_args_is_help |
Show help when no arguments are supplied. |
deprecated |
Mark the command as deprecated. |
rich_help_panel |
Rich help panel name. |
All other behavior matches Typer's built-in @app.command.
Example
import typer
from typer_alias import command
app = typer.Typer()
@command(
app,
aliases=("rm", "delete"),
)
def remove():
"""Remove an item."""
print("Removing...")
@command(
app,
name="list",
aliases=("ls",),
)
def get_all():
"""List all items."""
print("Listing...")
if __name__ == "__main__":
app()
Usage:
app remove
app rm
app delete
app list
app ls
Why?
Typer (and Click) do not provide an ergonomic way to define command aliases that also produce clean help output.
This package solves that by:
- registering each alias as a hidden command
- exposing a single visible command
- displaying aliases inline in the command list
Compatibility
- Python 3.12+
- Typer
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typer_alias-0.1.0.tar.gz.
File metadata
- Download URL: typer_alias-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33bca738b9d71af1809bb8b0f236e8ba53e067c8d6df97bbe5d5bed22c334d47
|
|
| MD5 |
ca76d821cb6d248d47bce6cf3d1e7f96
|
|
| BLAKE2b-256 |
db48a1a25b658c927e53fcf26dc0a423ee1c2ec05410df0c2c20c76096893b58
|
File details
Details for the file typer_alias-0.1.0-py3-none-any.whl.
File metadata
- Download URL: typer_alias-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deca5070fba7526ca96af79fc56118e9ef9df397ec17e5c2ae73cc6277db1f7e
|
|
| MD5 |
927dded9bebccecb877ee22597439c97
|
|
| BLAKE2b-256 |
5964ab81f4e5d0c0be334d7c27dff45178e6821d3b8224a92be9b05fab10cb4d
|