Coder Social home page Coder Social logo

cli-color-py's Introduction

cli-color-py 0.5.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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.