Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

click_compose-2025.10.27.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

click_compose-2025.10.27-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2Python 3

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

Hashes for click_compose-2025.10.27.tar.gz
Algorithm Hash digest
SHA256 b25481b2f8d288b68f3d41796319a616fe60043562c76d2b7d69a8b3fd6cc77f
MD5 849d9cd150f9e15b17b88087a5e39618
BLAKE2b-256 4c9920989736d99d9ee3ef5fafbaff9ee9c8cd11d59b15d27394ca76353acf97

See more details on using hashes here.

Provenance

The following attestation bundles were made for click_compose-2025.10.27.tar.gz:

Publisher: release.yml on adamtheturtle/click-compose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file click_compose-2025.10.27-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for click_compose-2025.10.27-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d6f3796e8f270107e86e52b765d362be6d6c5b6f8740660dac1093dcb34f5767
MD5 ddff1bfc1e822dee01b5d306e00df8e3
BLAKE2b-256 e45ef02a13b4a6a4a0dea6636a9ce0ef7b5bfda3697da95d921e39d0702acb5d

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page