click-extra
click-extra copied to clipboard
🌈 Extra colorization and configuration loading for Click.
trafficstars
What is Click Extra?
A collection of helpers and utilities for Click, the Python CLI framework.
It is a drop-in replacement with good defaults that saves you some boilerplate code. It also comes with workarounds and patches that have not reached upstream yet (or are unlikely to).
Example
It can transform this vanilla click CLI:

Into this:

To undestrand how we ended up with the result above, go read the tutorial.
Features
- Configuration file loader for:
TOMLYAMLJSON, with inline and block comments (Python-style#and Javascript-style//)INI, with extended interpolation, multi-level sections and non-native types (list,set, …)XML
- Download configuration from remote URLs
- Optional strict validation of configuration
- Search of configuration file from default user folder and glob patterns
- Respect of
CLI>Configuration>Environment>Defaultsprecedence --show-paramsoption to debug parameters defaults, values, environment variables and provenance- Colorization of help screens
-h/--helpoption names (see rant on other inconsistencies)--color/--no-coloroption flag- Recognize the
NO_COLORenvironment variable convention fromno-color.org - Colored
--versionoption - Colored
--verbosityoption and logs --time/--no-timeflag to measure duration of command execution- Platform recognition utilities (macOS, Linux and Windows)
- New conditional markers for
pytest:@skip_linux,@skip_macosand@skip_windows@unless_linux,@unless_macosand@unless_windows@destructiveand@non_destructive
- ANSI-capable Pygments lexers for shell session and console output
- Pygments styles and filters for ANSI rendering
- Fixes 30+ bugs from other Click-related projects
- Rely on
cloupto add:- option groups
- constraints
- subcommands sections
- aliases
- command suggestion (
Did you mean <subcommand>?)
Used in
Check these projects to get real-life examples of click-extra usage:
- Mail Deduplicate - A CLI to deduplicate similar emails.
- Meta Package Manager - A unifying CLI for multiple package managers.
Development
Development guidelines
are the same as
parent project mpm, from
which click-extra originated.