🌈 Extra colorization and configuration loading for Click.
Project description
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 some workarounds and patches that have not reached upstream yet (or are unlikely to).
Simple click example |
Same with click-extra |
from click import command, echo, option
@command()
@option("--count", default=1, help="Number of greetings.")
@option("--name", prompt="Your name", help="The person to greet.")
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
echo(f"Hello, {name}!")
if __name__ == "__main__":
hello()
|
from click_extra import command, echo, option
@command()
@option("--count", default=1, help="Number of greetings.")
@option("--name", prompt="Your name", help="The person to greet.")
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
echo(f"Hello, {name}!")
if __name__ == "__main__":
hello()
|
This example demonstrate the all-in-one package with its default options. You are still free to pick-up some of these options one-by-one, as documented below.
Features
- Configuration file loader for:
TOML
YAML
JSON
, with inline and block comments (Python-style#
and Javascript-style//
)INI
, with extended interpolation, multi-level sections and non-native types (list, sets, …)XML
- Download configuration from remote URLs
- Optional strict validation of configuration
- Automatic search of configuration file from default user folder
- Respect of
CLI > Configuration > Environment > Defaults
precedence - Colorization of help screens
-h/--help
option names (see rant on other inconsistencies)--color/--no-color
option flag- Recognize the
NO_COLOR
environment variable convention fromno-color.org
- Colored
--version
option - Colored
--verbosity
option and logs --time/--no-time
flag to measure duration of command execution- Platform recognition utilities (macOS, Linux and Windows)
- New conditional markers for
pytest
:@skip_linux
,@skip_macos
and@skip_windows
@unless_linux
,@unless_macos
and@unless_windows
@destructive
and@non_destructive
- Fixes 20+ bugs from other Click-related projects
- Rely on
cloup
to 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file click-extra-2.0.1.tar.gz
.
File metadata
- Download URL: click-extra-2.0.1.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92bc086bfe5030cab1d862809d4db7b17f17454c65e3d1f9c6bcea413691eff4 |
|
MD5 | db76efe5fd7f2c7a4b862528929c5374 |
|
BLAKE2b-256 | ea2dcf323619b36756ad92d7b2765270a7218389eff6af2662bb7e58630f57bd |
File details
Details for the file click_extra-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: click_extra-2.0.1-py3-none-any.whl
- Upload date:
- Size: 51.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2014c9f758d80f47116e0e7eb7e9bb1637d643f4142d8ce1b16b961b8bf2077 |
|
MD5 | efa5e825ed1850c668d5a0033bdbf3c3 |
|
BLAKE2b-256 | 6088d932da52afc5a1eac32345ab789349f6d03f7e76ee002e1207a0f2367afa |