Skip to main content

🌈 Extra colorization and configuration loading for Click.

Project description

Click Extra

Last release Python versions Unittests status Documentation status Coverage status

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()
click CLI help screen click-extra CLI help screen

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 from no-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:

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

click-extra-2.1.1.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

click_extra-2.1.1-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

Details for the file click-extra-2.1.1.tar.gz.

File metadata

  • Download URL: click-extra-2.1.1.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for click-extra-2.1.1.tar.gz
Algorithm Hash digest
SHA256 a0ee6dcc2b42c3ae3f2f0172b830a8b215fed5802249bb98c7ef979d7030fd40
MD5 567c75bd08f543dca982c419f33ba7fe
BLAKE2b-256 c4d75ee25f15f553891d508a4a2755532712033cc95eb4ba38770f268fc2771f

See more details on using hashes here.

File details

Details for the file click_extra-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: click_extra-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 45.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.13

File hashes

Hashes for click_extra-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24b5abf1c283058e74a300d4ed10b3c8b45bcb4e11c255bf963de70743462547
MD5 404b00392c588b8170cd52b6465f8e30
BLAKE2b-256 3e149c96b8cab8c0bf3ff775d9a52434403cfa11411045ed9bf6e972effcd5fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page