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
- Flexible Color Formats: Full support for HEX strings, RGB tuples, and built-in ANSI constants.
- Global Configuration: Clean, centralized setup to define your project's default visual hierarchy once and reuse it everywhere.
- 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.BOLDStyle.DIMStyle.ITALICStyle.UNDERLINEStyle.BLINKStyle.REVERSEStyle.STRIKETHROUGH
Available Colors (Colors.*)
Color.BLACKColor.REDColor.GREENColor.YELLOWColor.BLUEColor.MAGENTAColor.CYANColor.WHITE
For fast, standard terminal coloring, you can import and use the Color and Style Enums directly:
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inkterm-0.1.2.tar.gz.
File metadata
- Download URL: inkterm-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baf140cce5c4cd7b4fe95a5130817c21faafd6bbe52146e91c9d73d65dbcf5fc
|
|
| MD5 |
90dfea4a535197d720a294d6906b3bcc
|
|
| BLAKE2b-256 |
e7a9bfd25a7abcc13af17ae85cd2a47ee65185167bfd44477db766e6fd414460
|
File details
Details for the file inkterm-0.1.2-py3-none-any.whl.
File metadata
- Download URL: inkterm-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3235050ee6c1c7a97b0a9ef6eaeb77cd8779347e3bb9cc31c903daf6fb39935
|
|
| MD5 |
96273e236d51837a7793672bde9ade05
|
|
| BLAKE2b-256 |
dd6e8dcddb732c72772c8932961217fd667d1e80906a6d547cb607cf61307f19
|