Composable Click callback utilities for building flexible CLI applications.
Project description
Composable Click callback utilities for building flexible CLI applications.
Installation
$ pip install click-compose
Or with uv:
$ uv add click-compose
Quick Start
click-compose provides two main utilities for composing Click callbacks:
multi_callback
Combine multiple callbacks into a single callback that applies them in sequence:
import click
from click_compose import multi_callback
def validate_positive(ctx, param, value):
if value <= 0:
raise click.BadParameter("Must be positive")
return value
def validate_max_100(ctx, param, value):
if value > 100:
raise click.BadParameter("Must be <= 100")
return value
@click.command()
@click.option(
"--count",
type=int,
callback=multi_callback([validate_positive, validate_max_100]),
)
def cmd(count):
click.echo(f"Count: {count}")
sequence_validator
Apply a validator to each element in a sequence (useful with multiple=True):
import click
from click_compose import sequence_validator
def validate_positive(ctx, param, value):
if value <= 0:
raise click.BadParameter("Must be positive")
return value
@click.command()
@click.option(
"--numbers",
multiple=True,
type=int,
callback=sequence_validator(validate_positive),
)
def cmd(numbers):
click.echo(f"Sum: {sum(numbers)}")
Documentation
See the full documentation.
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 click_compose-2025.10.27.tar.gz.
File metadata
- Download URL: click_compose-2025.10.27.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b25481b2f8d288b68f3d41796319a616fe60043562c76d2b7d69a8b3fd6cc77f
|
|
| MD5 |
849d9cd150f9e15b17b88087a5e39618
|
|
| BLAKE2b-256 |
4c9920989736d99d9ee3ef5fafbaff9ee9c8cd11d59b15d27394ca76353acf97
|
Provenance
The following attestation bundles were made for click_compose-2025.10.27.tar.gz:
Publisher:
release.yml on adamtheturtle/click-compose
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
click_compose-2025.10.27.tar.gz -
Subject digest:
b25481b2f8d288b68f3d41796319a616fe60043562c76d2b7d69a8b3fd6cc77f - Sigstore transparency entry: 644360297
- Sigstore integration time:
-
Permalink:
adamtheturtle/click-compose@05a2663927306ecb9d19b2e741899d9ad566bb2c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/adamtheturtle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@05a2663927306ecb9d19b2e741899d9ad566bb2c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file click_compose-2025.10.27-py2.py3-none-any.whl.
File metadata
- Download URL: click_compose-2025.10.27-py2.py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6f3796e8f270107e86e52b765d362be6d6c5b6f8740660dac1093dcb34f5767
|
|
| MD5 |
ddff1bfc1e822dee01b5d306e00df8e3
|
|
| BLAKE2b-256 |
e45ef02a13b4a6a4a0dea6636a9ce0ef7b5bfda3697da95d921e39d0702acb5d
|
Provenance
The following attestation bundles were made for click_compose-2025.10.27-py2.py3-none-any.whl:
Publisher:
release.yml on adamtheturtle/click-compose
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
click_compose-2025.10.27-py2.py3-none-any.whl -
Subject digest:
d6f3796e8f270107e86e52b765d362be6d6c5b6f8740660dac1093dcb34f5767 - Sigstore transparency entry: 644360300
- Sigstore integration time:
-
Permalink:
adamtheturtle/click-compose@05a2663927306ecb9d19b2e741899d9ad566bb2c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/adamtheturtle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@05a2663927306ecb9d19b2e741899d9ad566bb2c -
Trigger Event:
workflow_dispatch
-
Statement type: