Skip to main content

Minimalistic way to add colors to your terminal output

Project description

cli-color-py 0.6.0

Library to output colored text to the terminal.

This library is designed to be subjectively more elegant and readable than alternatives I was able to find.

Compared to some alternatives cli-color-py currently has less colors available; only supporting 14 of the 256+ supported colors in most (modern) terminals.

Elegant/Minimalistic access to colors and styles

from cli_color import red, bright_yellow, green, bold

print(green("hello"))
print(bold(red("world")))

print(bright_yellow("background", bg=True))

Low level access to colors and styles

Low level access however is a bit less elegant as for colors you need to explicitly choose between the foreground or background.

cli-color-py isn't really made for doing stuff like this, but it is possible

from cli_color.color import Color, Attribute

print(
    Color.RED.default(),
    "Red text",
    Color.CYAN.background(),
    "cyan background",
    Attribute.RESET
)

Colors

Supported colors are currently: black, red, green, yellow, blue, magenta, cyan, white, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan

Background colors can be used by setting bg to True i.e. red("text", bg=True)

NOTE: background and bright colors are not officially supported

Attributes or 'styles'

Supported attributes are: reset, bold, underline, blink

Attributes work similar to Colors but cannot be displayed on the background:

from cli_color import blink

print(blink("LOTTERY WINNER!!!"))

More colors?

It's possible to add 256 color support but this currently seems unnecessary to me personally.

The 14 available colors should be more than enough for any cli tool/script and will work nicer with most color schemes.

Windows

for Windows a modern terminal (compared to cmd/powershell) is required like Windows Terminal or any other modern terminal on windows that uses ANSI colors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli-color-py-0.6.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file cli-color-py-0.6.0.tar.gz.

File metadata

  • Download URL: cli-color-py-0.6.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for cli-color-py-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d7e09550bbb6ba8e92a466c4da9f5632c9e52cf77108c5d9e08d195fe7b0063f
MD5 d39e391df6c1181f62c5a7e04d8596aa
BLAKE2b-256 14a8cdea3adbff4debb8f57f811c700b499735e0ea398e0dcefceddf6c3acffe

See more details on using hashes here.

Supported by

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