Skip to main content

Overview

Latest release on PyPI Supported versions PyPI - Downloads Tests status Coverage Status Documentation Status (master branch) Donate with PayPal

Cloup — originally from “Click + option groups” — enriches Click with several features that make it more expressive and configurable:

  • option groups and an (optional) help section for positional arguments

  • constraints, like mutually_exclusive, that can be applied to option groups or to any group of parameters, even conditionally

  • subcommand aliases

  • subcommands sections, i.e. the possibility of organizing the subcommands of a Group in multiple help sections

  • a themeable HelpFormatter that:

    • has more parameters for adjusting widths and spacing, which can be provided at the context and command level

    • use a different layout when the terminal width is below a certain threshold in order to improve readability

  • suggestions like “did you mean <subcommand>?” when you mistype a subcommand.

Moreover, Cloup improves on IDE support providing decorators with detailed type hints and adding the static methods Context.settings() and HelpFormatter.settings() for creating dictionaries of settings.

Cloup is statically type-checked with MyPy in strict mode and extensively tested against multiple versions of Python with nearly 100% coverage.

A simple example

from cloup import (
    HelpFormatter, HelpTheme, Style,
    command, option, option_group
)
from cloup.constraints import RequireAtLeast, mutually_exclusive

# Check the docs for all available arguments of HelpFormatter and HelpTheme.
formatter_settings = HelpFormatter.settings(
    theme=HelpTheme(
        invoked_command=Style(fg='bright_yellow'),
        heading=Style(fg='bright_white', bold=True),
        constraint=Style(fg='magenta'),
        col1=Style(fg='bright_yellow'),
    )
)

# In a multi-command app, you can pass formatter_settings as part
# of your context_settings so that they are propagated to subcommands.
@command(formatter_settings=formatter_settings)
@option_group(
    "Cool options",
    option('--foo', help='This text should describe the option --foo.'),
    option('--bar', help='This text should describe the option --bar.'),
    constraint=mutually_exclusive,
)
@option_group(
    "Other cool options",
    "This is the optional description of this option group.",
    option('--pippo', help='This text should describe the option --pippo.'),
    option('--pluto', help='This text should describe the option --pluto.'),
    constraint=RequireAtLeast(1),
)
def cmd(**kwargs):
    """This is the command description."""
    pass

if __name__ == '__main__':
    cmd(prog_name='invoked-command')
Basic example --help screenshot

If you don’t provide --pippo or --pluto:

Usage: invoked-command [OPTIONS]
Try 'invoked-command --help' for help.

Error: at least 1 of the following parameters must be set:
  --pippo
  --pluto

This simple example just scratches the surface. Read more in the documentation (links below).

Supporting the project

Designing, testing and documenting a library takes a lot of time. The most concrete way to show your appreciation and to support future development is by donating. Any amount is appreciated.

Donate with PayPal

Apart from that, you can help the project by starring it on GitHub, reporting issues, proposing improvements and contributing with your code!

Metadata

Release files for cloup 3.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cloup 3.0.4
File Size Uploaded Provenance Actions
cloup-3.0.4.tar.gz 225.7 kB Without provenance Details for cloup-3.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cloup 3.0.4
File Interpreter ABI Platform Actions
cloup-3.0.4-py2.py3-none-any.whl Python 3, Python 2 none any Details for cloup-3.0.4-py2.py3-none-any.whl

Total release size: 280.0 kB

Release files / cloup-3.0.4.tar.gz

Download URL cloup-3.0.4.tar.gz
Size 225.7 kB
Tags Source
SHA-256 checksum
How to use checksums
658111e2f49b8256a822dac5fa0205bf64109fdefc435f39923490a32b13ec09
BLAKE2b-256 checksum
How to use checksums
e4951cdc36a95ffb2a48542b7439d5a7ba6cba0fa90208be913c01edcf267ca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / cloup-3.0.4-py2.py3-none-any.whl

Download URL cloup-3.0.4-py2.py3-none-any.whl
Size 54.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
57604639a754a501ce4168faeb629e2ca523942e0ae4e180d832a953cf87ea84
BLAKE2b-256 checksum
How to use checksums
4f04f40b672c32e8f0544b6c5613fc29142514897f99bfdb6ad06f90622f4b2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for cloup 3.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page