{"id":7084,"library":"click-command-tree","title":"click-command-tree","description":"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.","status":"active","version":"1.2.0","language":"en","source_language":"en","source_url":"https://github.com/whwright/click-command-tree","tags":["click","cli","command-line-interface","plugin","tree","documentation"],"install":[{"cmd":"pip install click-command-tree","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency as `click-command-tree` is a plugin for Click applications. Tested with Click versions 5.x through 8.1.x.","package":"click"},{"reason":"Required for dynamic loading of the `click-command-tree` plugin via entry points.","package":"click-plugins"}],"imports":[{"note":"Standard import for defining Click commands and groups.","symbol":"click","correct":"import click"},{"note":"Required to register `click-command-tree` as a plugin to a Click group.","symbol":"with_plugins","correct":"from click_plugins import with_plugins"},{"note":"`pkg_resources` is deprecated in favor of `importlib.metadata` for Python 3.8+ for accessing entry points.","wrong":"@with_plugins(pkg_resources.iter_entry_points('click_command_tree'))","symbol":"importlib.metadata.entry_points","correct":"import importlib.metadata\n@with_plugins(importlib.metadata.entry_points(group='click_command_tree'))"}],"quickstart":{"code":"import click\nfrom click_plugins import with_plugins\nimport importlib.metadata\n\n@with_plugins(importlib.metadata.entry_points(group=\"click_command_tree\"))\n@click.group()\ndef cli():\n    \"\"\"A sample CLI to demonstrate click-command-tree.\n\n    Try: `python your_cli.py tree`\n    \"\"\"\n    pass\n\n@cli.group()\ndef users():\n    \"\"\"Manage users.\n    \"\"\"\n    pass\n\n@users.command(name=\"add\")\ndef add_user():\n    \"\"\"Add a new user.\n    \"\"\"\n    click.echo(\"Adding user...\")\n\n@users.command(hidden=True)\ndef delete_user():\n    \"\"\"Delete a user (hidden command).\n    \"\"\"\n    click.echo(\"Deleting user...\")\n\n@cli.command()\ndef config():\n    \"\"\"Configure settings.\n    \"\"\"\n    click.echo(\"Configuring settings...\")\n\nif __name__ == '__main__':\n    cli()","lang":"python","description":"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."},"warnings":[{"fix":"If you relied on `hidden` commands appearing in the `tree` output for internal tooling or documentation, this behavior has changed. To include them, you would need to modify the `click-command-tree` source or find an alternative method.","message":"The `tree` command no longer displays commands marked with `hidden=True` in their Click definition.","severity":"breaking","affected_versions":"1.1.1 and later"},{"fix":"If you were programmatically parsing the output of the `tree` command, your parsing logic may need to be updated to account for the inclusion of docstrings.","message":"The output format of the `tree` command was altered to include docstrings for commands and groups.","severity":"breaking","affected_versions":"1.1.0 and later"},{"fix":"For Python 3.8 and later, use `importlib.metadata.entry_points(group=\"click_command_tree\")`. For older Python versions, `pkg_resources.iter_entry_points('click_command_tree')` might be necessary, though the library itself targets Python 3.8-3.12.","message":"Correctly registering the plugin requires using `click-plugins` with the appropriate entry point group, and the method for retrieving entry points (`importlib.metadata` vs `pkg_resources`) varies by Python version.","severity":"gotcha","affected_versions":"All versions (behavioral differences in Python runtime)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you have `click-plugins` installed (`pip install click-plugins`) and that your root `click.group` is decorated with `@with_plugins(importlib.metadata.entry_points(group=\"click_command_tree\"))` (or `pkg_resources` for older Python).","cause":"The `click-command-tree` plugin was not correctly registered with your Click application's root group, or the `click-plugins` dependency is missing.","error":"Error: No such command 'tree'."},{"fix":"Update your code to use `importlib.metadata.entry_points` instead of `pkg_resources.iter_entry_points`. For example: `import importlib.metadata` and then `@with_plugins(importlib.metadata.entry_points(group=\"click_command_tree\"))`.","cause":"`pkg_resources` is deprecated, and its `iter_entry_points` function may not be available or function as expected in newer Python environments, particularly Python 3.8+.","error":"AttributeError: module 'pkg_resources' has no attribute 'iter_entry_points'"}]}