It should be easy to write a good CLI in Python. Click makes it so. But there is still hundrends of tweaks to implement by yourself to have a user-friendly CLI.
Click Extra is a ready-to-use wrapper around Click to make your CLI look good and behave well. It is a drop-in replacement with good defaults that saves lots of boilerplate code and frustration by making all parts working together.
It also comes with workarounds and patches that have not reached upstream yet (or are unlikely to).
It transforms this vanilla click CLI:
Into this:
To undestrand how we ended up with the result above, go read the tutorial.
- Configuration file loader for:
TOMLYAMLJSON,JSON5,JSONCandHJSONINI, with extended interpolation, multi-level sections and non-native types (list,set, β¦)XML
- Automatic inference of the configuration file structure from your CLI's options
- Remote loading of configuration from URLs
- Optional strict validation of configuration
- Respect the default application path on each platform (XDG spec. on Linux)
- Glob search patterns for configuration files
- A
--no-configoption to disable configuration file loading - Respect of
CLI>Configuration>Environment>Defaultsprecedence - Normalization and discoverability of environment variables
--show-paramsoption to debug parameters defaults, values, environment variables and provenance- Click parameters introspection
- Colorization of help screens at the semantic-level of options, parameters, subheadings, choices, metavars and defaults
- Global
show_envvaroption to display all environment variables in help screens -h/--helpoption names (see rant on other inconsistencies)--color/--no-coloroption flag--telemetry/--no-telemetryflag to opt-in/out of tracking code- Recognize traditional environment variable conventions:
NO_COLORfromno-color.orgDO_NOT_TRACKfromconsoledonottrack.com
- Colored
--versionoption - Colored
--verbosityoption and logs --time/--no-timeflag to measure duration of command execution- Global
show_choicesto activate selection of choices on user input prompts - Lazy-loading of subcommands from module paths to speed up CLI startup time
click:exampleandclick:runSphinx directives in MyST Markdown and reStructuredText to document CLI source code and their execution- Inline testing of CLI examples in documentation
- ANSI-capable Pygments lexers for shell session and console output
- Fixes 50+ bugs from other Click-related projects
- Rely on Cloup to add:
- option groups
- constraints
- subcommands sections
- aliases
- command suggestion (
Did you mean <subcommand>?)
Check these projects to get real-life examples of click-extra usage:
Meta Package Manager - A unifying CLI for multiple package managers.
Mail Deduplicate - A CLI to deduplicate similar emails.
fireproxng - A rewrite of the fireprox tool.
agent-catalog - Couchbase agent catalog.
badger-proxy - An mDNS-based reverse proxy for naming services on a local network.
Feel free to send a PR to add your project in this list if you are relying on Click Extra in any way.
Development guidelines
are the same as
parent project mpm, from
which click-extra originated.

