click-command-tree

1.2.0 · active · verified Thu Apr 16

click-command-tree is a Click plugin that provides a `tree` command to any Click CLI application, allowing users to visualize the command hierarchy. It is actively maintained, with version 1.2.0 released on March 24, 2024, and maintains a consistent release cadence for updates and features.

Common errors

Warnings

Install

Imports

Quickstart

This example creates a simple Click CLI with nested commands and demonstrates how to integrate `click-command-tree` to generate a command tree. Run `python your_cli.py tree` to see the output. Note how `delete_user` (marked `hidden=True`) is excluded from the tree output due to changes in version 1.1.1.

import click
from click_plugins import with_plugins
import importlib.metadata

@with_plugins(importlib.metadata.entry_points(group="click_command_tree"))
@click.group()
def cli():
    """A sample CLI to demonstrate click-command-tree.

    Try: `python your_cli.py tree`
    """
    pass

@cli.group()
def users():
    """Manage users.
    """
    pass

@users.command(name="add")
def add_user():
    """Add a new user.
    """
    click.echo("Adding user...")

@users.command(hidden=True)
def delete_user():
    """Delete a user (hidden command).
    """
    click.echo("Deleting user...")

@cli.command()
def config():
    """Configure settings.
    """
    click.echo("Configuring settings...")

if __name__ == '__main__':
    cli()

view raw JSON →