{"id":14488,"library":"click-compose","title":"Composable Click Utilities","description":"Click-compose is a Python library that provides composable utilities for enhancing Click callback functions, enabling the construction of flexible and modular command-line interface (CLI) applications. It extends the core functionality of the Click framework by offering tools to easily chain and combine command logic. The library is actively maintained, with its current version being 2025.10.27.3, and follows a frequent release cadence.","status":"active","version":"2025.10.27.3","language":"en","source_language":"en","source_url":"https://github.com/adamtheturtle/click-compose","tags":["CLI","Click","utility","callbacks","composition"],"install":[{"cmd":"pip install click-compose","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for building command-line interfaces, as 'click-compose' provides utilities for Click callbacks.","package":"click"}],"imports":[{"note":"Assumed primary import for composing groups of callbacks.","symbol":"callback_group","correct":"from click_compose import callback_group"},{"note":"Assumed utility for defining composable Click options.","symbol":"composed_option","correct":"from click_compose import composed_option"}],"quickstart":{"code":"import click\nfrom click_compose import callback_group, composed_option\n\n@callback_group()\n@click.command()\n@click.option('--name', default='World', help='The name to greet.')\ndef cli(name):\n    \"\"\"A simple CLI greeting utility.\"\"\"\n    click.echo(f'Hello, {name}!')\n\n@cli.command()\n@composed_option('--caps', is_flag=True, help='Say hello in uppercase.')\ndef shout(caps, name):\n    \"\"\"Greets in an excited manner.\"\"\"\n    message = f'HEY {name.upper()}!' if caps else f'Hey {name}!'\n    click.echo(message)\n\nif __name__ == '__main__':\n    cli()","lang":"python","description":"This quickstart demonstrates a basic Click CLI application using `click-compose` to create a `callback_group` and a `composed_option`. The `cli` command acts as a group, and `shout` is a subcommand that uses a composed option to conditionally output an uppercase greeting. This illustrates how to extend Click's decorator-based approach with additional composition logic."},"warnings":[{"fix":"Check the 'click-compose' release notes for compatibility with your 'click' version. Pin 'click' to a known compatible version if issues arise.","message":"Major version updates of the underlying 'click' library may introduce incompatibilities that require 'click-compose' to release a new version or for users to adjust their code.","severity":"breaking","affected_versions":"<2025.10.x.x"},{"fix":"Always place 'click-compose' decorators above standard 'click' decorators, or consult the documentation for specific decorator stacking order. Generally, more 'inner' decorators (affecting the immediate function) should be closer to the function definition.","message":"Incorrect order of decorators (e.g., Click's @command before @callback_group or @composed_option) can lead to unexpected behavior or errors, as Click's decorators often wrap the function directly.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure that `click` commands modified by `click-compose` are always invoked correctly within the Click ecosystem, typically through a parent `click.group` or `cli()` entry point, not as standalone Python functions.","cause":"Attempting to call a Click command directly that has been modified by a 'click-compose' decorator in a way that changes its callable interface without proper invocation via Click's `Context.invoke` or `CliRunner`.","error":"TypeError: 'Command' object is not callable"},{"fix":"Run `pip install click-compose` to install the library.","cause":"The 'click-compose' package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'click_compose'"}],"ecosystem":"pypi"}