Cloup — originally from 'Click + option groups' — enriches the popular Click library with several features that make command-line interfaces more expressive and configurable. These include option groups, constraints (e.g., mutually exclusive parameters), subcommand aliases, subcommand sections, and a themeable help formatter. The library, currently at version 3.0.9, is under active development, statically type-checked with MyPy, and extensively tested.
pip install cloupVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a command with custom help formatting, option groups, and constraints. It uses `option_group` to logically group related options and applies `mutually_exclusive` and `RequireAtLeast` constraints.
Review any code directly interacting with `HelpTheme`'s internal structure or inheritance. Adapt to `dataclass` behavior if necessary.
Upgrade Python to 3.8 or newer, or pin Cloup to a version `<=3.0.5`.
Ensure consistent use of `cloup.Context` where Cloup features are utilized, or upgrade to `cloup>=3.0.3` which aims to improve compatibility.
Upgrade to Cloup v3.0.9 or newer to resolve the `click.__version__` deprecation warning.
Upgrade to Cloup v3.0.7 or newer to ensure constraints function correctly with all option name configurations.
If option groups or constraints are needed for a `cloup.Group`, consider using `cloup.Command` for the top-level CLI or explicitly subclass `cloup.Group` and add the necessary mixins (e.g., `OptionGroupMixin`, `ConstraintMixin`) as described in Cloup's advanced documentation.
Ensure that the required number of options within the constrained group are provided when invoking the command. For example, if `--option1` or `--option2` is required, provide one of them: `your_command --option1 value`.
Install the cloup library using pip: `pip install cloup` or activate the correct Python environment where cloup is installed.
Ensure you are consistently using `cloup.HelpFormatter` when working with Cloup's advanced formatting features. You can define `formatter_class=cloup.HelpFormatter` in your command's `context_settings` or use `cloup.Command` which uses it by default.
To use subcommand sections, ensure your group is created using `@cloup.group` (which returns a `cloup.Group` by default) or explicitly make your group class inherit from `cloup.Group` or `cloup.SectionMixin`.