Click Aliases

1.0.5 · active · verified Sat Apr 11

click-aliases is a Python library that extends Click, a popular CLI creation kit, by allowing developers to assign multiple distinct aliases to commands and groups. It addresses Click's lack of built-in 'true' command aliasing (beyond prefix matching) by providing a custom group class. The current version is 1.0.5, released in October 2024, and it generally follows a maintenance release cadence.

Warnings

Install

Imports

Quickstart

This example demonstrates how to set up a Click CLI with `click-aliases`. The `ClickAliasedGroup` is passed as the class for the main Click group, and then individual commands can specify aliases using the `aliases` argument in the `@cli.command()` decorator.

import click
from click_aliases import ClickAliasedGroup

@click.group(cls=ClickAliasedGroup)
def cli():
    """A simple CLI with aliases."""
    pass

@cli.command(aliases=['create', 'mk'])
def make():
    """Makes something new."""
    click.echo('Making something...')

@cli.command(aliases=['rm', 'delete'])
def remove():
    """Removes something."""
    click.echo('Removing something...')

if __name__ == '__main__':
    cli()

view raw JSON →