Skip to main content

Color labrary for CLI

Project description

Inkterm

A lightweight, fluent, and modern tool for decorating terminal text. Essential for building clean Command Line Interfaces (CLI) and console applications without cluttering your code with raw ANSI escape sequences.

Installation

Install inkterm via pip:

pip install inkterm

Key Features

  1. Flexible Color Formats: Full support for HEX strings, RGB tuples, and built-in ANSI constants.
  2. Global Configuration: Clean, centralized setup to define your project's default visual hierarchy once and reuse it everywhere.
  3. Smart Prefixes: Manage consistent log levels (info, error, success) seamlessly.

Quick Start

Instead of using Python's native print() and manually concatenating colors, use the write() function for instant, clean styling:

from inkterm import write

write("Hello world!", color="#7c7c7c")

The write() Function Reference

Argument Default Type Description
text Required str The message to be printed.
color None str / tuple / Color Foreground color (HEX string, RGB tuple, or Color Enum).
background None str / tuple / Color Background color (HEX string, RGB tuple, or Color Enum).
styles None list A list of text formats (e.g., [Style.BOLD]).
prefix None str Name of a predefined prefix from your global config.
payload False bool If True, returns the formatted ANSI string instead of printing it.

Centralized Global Settings

To maximize code readability, configure your visual styles at your application's entry point (e.g., main.py).

The config() Reference

Argument Default Type Description
reset_color True` bool Automatically appends an ANSI reset sequence at the end of every line.
default_text_color None str / tuple / Color Fallback foreground color for all standard text.
default_prefix None str The prefix name used by default when write() specifies none.
prefix None dict A dictionary mapping names to pre-styled components via label().

Advanced Configuration Example

# main.py

from inkterm import config, write, label, Style, Color

config(
    # Set default text color using an Enum constant
    default_text_color=Color.WHITE,

    # Build and register custom prefixes
    prefix={
        "info": label("[INFO]", color="#57bf4b", styles=[Style.BOLD]),
        "error": label("[ERROR]", color=Color.RED, styles=[Style.BOLD, Style.UNDERLINE]),
    },

    # Automatically use the 'info' prefix if none is passed to write()
    default_prefix="info"
)

# Standard print using the default "info" prefix
write("System is running smoothly.")  # Output: [INFO] System is running smoothly.

# Overriding the prefix for specific logs
write("Database connection failed!", prefix="error")  # Output: [ERROR] Database connection failed!

Built-in Constants

For fast, standard terminal coloring, you can import and use the Color and Style Enums directly:

Available Styles (Style.*)

  • Style.BOLD
  • Style.DIM
  • Style.ITALIC
  • Style.UNDERLINE
  • Style.BLINK
  • Style.REVERSE
  • Style.STRIKETHROUGH

Available Colors (Colors.*)

  • Color.BLACK
  • Color.RED
  • Color.GREEN
  • Color.YELLOW
  • Color.BLUE
  • Color.MAGENTA
  • Color.CYAN
  • Color.WHITE

For fast, standard terminal coloring, you can import and use the Color and Style Enums directly:

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

inkterm-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inkterm-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file inkterm-0.1.0.tar.gz.

File metadata

  • Download URL: inkterm-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for inkterm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6dc58dd46f090377b76ffe32c86d6cf8ebb9af0578e6d6b9b47cca1ebc6fd6b9
MD5 ba0d823492fed3ca8e879ef1d833f9ef
BLAKE2b-256 e4d6d511532ff45a4cb343f805526d79e7d8c7200e0637afaf091191c1df7854

See more details on using hashes here.

File details

Details for the file inkterm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: inkterm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for inkterm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9651ddc212d8a0ff4d3ec235172954da068324c2bfda7d97526623dbc3e148bc
MD5 4b1ba536a4ce8c92d506ee4b87313a2c
BLAKE2b-256 38c903e3badcbbff92d459b3bff9e303573fde738b9a29737f11e6345d165bc7

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