Skip to main content

Lightweight CLI library with ANSI colors, boxes and progress bar (stdlib only)

Project description

TurboConsole

Lightweight Python library for terminal output with ANSI colors, boxes, and a progress bar. No external dependencies (standard library only). Compatible with Windows, macOS, and Linux.

Installation

From PyPI (when published):

pip install turboconsole

From source (development):

git clone https://github.com/FranciscoZanonDP/TurboConsole.git
cd TurboConsole
pip install -e .

Or add the project root to PYTHONPATH to use without installing.

Quick start: from turboconsole import Turbo; Turbo().info("Ready")

Usage

from turboconsole import Turbo

t = Turbo()
t.clear()
t.info("Library initialized on " + t.system)
t.success("All good")
t.warning("Watch out")
t.error("Something failed")

t.box("Content here.\nMultiple lines.", title="Title")

for item in t.progress_bar(range(100), prefix="Processing: "):
    pass  # your logic

Version

To get the package version:

from turboconsole import __version__
# or: import turboconsole; print(turboconsole.__version__)

Constructor

Turbo(force_color=False, no_emoji=False)

  • force_color: If True, use ANSI colors even when stdout is not a TTY (e.g. in redirected logs).
  • no_emoji: If True, log messages have no emoji (only [INFO], [OK], [WARN], [ERROR] labels).

API

Method Description
clear() / limpiar() Clear the screen (ANSI on all OS when VT and TTY; else cls / clear)
info(text) Blue message (text optional; None treated as empty)
success(text) Green message (text optional; None treated as empty)
warning(text) Yellow message (text optional; None treated as empty)
error(text) Red message (text optional; None treated as empty)
box(content, title="", max_width=None, *, texto=..., titulo=...) Unicode box around text; content and title optional (None as empty). Deprecated aliases: texto, titulo. max_width limits line width (default: terminal columns - 4 when TTY).
progress_bar(iterable, prefix="", width=40, total=None, prefijo=...) Generator with progress bar on the same line; prefix for label; total for percentage when iterable has no len(). For correct percentage, total should match the number of items. Deprecated alias: prefijo.
system Property: detected OS

Redirection and non-TTY

When stdout is not a TTY (e.g. python script.py > out.txt or in a pipe):

  • No ANSI codes are sent (plain output).
  • The progress bar does not update in place; only a new line is printed when done.

This avoids ANSI in files and overwritten lines when redirecting.

Known limits

  • progress_bar: width is clamped to 1–120.
  • box: When there is no terminal (e.g. no TTY), max_width defaults to None and long lines are not truncated; pass max_width explicitly if needed.

On Windows, ctypes is used to enable ANSI sequences in CMD/PowerShell, and console mode is restored on process exit.

Tests

python -m unittest discover -s tests -v

Lint

With dev dependencies installed (pip install -e ".[dev]"):

ruff check turboconsole/ tests/

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

turboconsole-1.0.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

turboconsole-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file turboconsole-1.0.0.tar.gz.

File metadata

  • Download URL: turboconsole-1.0.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for turboconsole-1.0.0.tar.gz
Algorithm Hash digest
SHA256 871bcac75dabe98a1677067dbedc7e7728099fabf6423b2a167156fda065ae02
MD5 2f88021e4c5faf8d1e2e9ae4332c61ca
BLAKE2b-256 43428d413f97689070d2d7f89ef2e59aff0d4db0336fde70921b43bd693a7654

See more details on using hashes here.

File details

Details for the file turboconsole-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: turboconsole-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for turboconsole-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdd9421dbea5ebb411d033b5795f007357fb29d2ac8612a1eb77664ddd6c6538
MD5 5d3fd22cb0cf2a1a1fbd7f0b1f8eb6de
BLAKE2b-256 7cf1c62bc159ce91c9f5f79c580cd97b2129d9a7c143401a41058f2c988a322b

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