Skip to main content

Tiny terminal UI utility for clean, colorful build output.

Project description

tuiro

CI Release PyPI - Version

tuiro is a tiny terminal UI helper designed for clean, readable, and structured output in build scripts and command‑line tools. It provides simple utilities for sections, banners, status messages, command logging, spinners, and themed output without introducing heavy dependencies or complex abstractions.

tuiro began as an internal utility inside the TactileBrowser project. It is now available as a standalone library for any script or tool that wants clear and consistent terminal output.

Features

  • Lightweight and dependency‑free
  • ANSI color support with optional CI mode
  • Built‑in themes and user‑defined palettes
  • Section and subsection headers
  • Informational, warning, success, and error messages
  • Command logging for build steps
  • Animated spinners for long-running operations
  • Centered banners with automatic terminal width detection
  • A simple step context manager for build phases
  • A minimal CLI for quick verification and theme testing

Installation

pip install tuiro

For development:

uv pip install -e .

Usage

Basic example:

from tuiro import TUI

tui = TUI()
tui.banner("Build")
tui.section("Environment")
tui.info("Checking dependencies")
tui.success("All checks passed")

Example output (colors omitted):

╔══════════════════════════════════════════════════════════╗
║                          Build                           ║
╚══════════════════════════════════════════════════════════╝

────────────────────────────────────────────────────────────
  Environment
────────────────────────────────────────────────────────────
[*] Checking dependencies
[OK] All checks passed

Spinners

Spinners provide visual feedback for long-running operations:

# Context manager (automatic success)
with tui.spinner("Downloading packages"):
    download()

# Context manager with custom message
with tui.spinner("Building project") as s:
    build()
    s.succeed("Build completed in 3.2s")

# Manual control
spinner = tui.spinner("Running tests")
spinner.start()
run_tests()
spinner.stop(status="success", final_message="42 tests passed")

# Convenience methods
spinner.succeed("Done!")
spinner.fail("Something went wrong")
spinner.warn("Completed with warnings")

Spinners automatically degrade to static messages in CI mode or non-TTY environments.

Themes

tuiro supports both built‑in themes and user‑defined palettes.

Built‑in themes

  • default
  • mono
  • pastel

Use a theme by name:

tui = TUI(theme="pastel")

Custom palettes

Palettes live in tuiro.palette. Users can define their own palette by subclassing Palette:

from tuiro.palette import Palette
from tuiro.colors import Colors

class MyPalette(Palette):
    success = Colors.BRIGHT_GREEN
    info = Colors.BRIGHT_CYAN

Then pass it to TUI:

tui = TUI(theme=MyPalette)

or:

tui = TUI(theme=MyPalette())

Note: The CLI --theme flag accepts only built‑in theme names from PROFILES. Custom palettes must be provided from Python code.

CLI

tuiro includes a small demonstration CLI:

tuiro

Flags:

tuiro --ci
tuiro --no-color
tuiro --theme pastel
tuiro --help
tuiro --version

Behavior:

  • --ci disables colors
  • --no-color also disables colors
  • If both are provided, colors remain disabled
  • --theme NAME selects a built‑in theme
  • --help lists available themes

Example:

tuiro --ci --theme mono

API

TUI(ci_mode: bool = False, theme: str | Palette = "default")

Creates a new terminal UI helper.

section(title: str)

Prints a high‑visibility section header.

subsection(title: str)

Prints a smaller subsection header.

banner(title: str)

Prints a centered banner.

Status messages

info(message: str)
success(message: str)
warning(message: str)
error(message: str)

command(cmd: str | list[str])

Prints a command being executed. Lists are joined with spaces.

result(label: str, value: str)

Prints a key‑value result line.

table(rows: list[tuple[str, str]])

Prints a simple two‑column table aligned on the left column.

spinner(message: str) -> Spinner

Creates an animated spinner for long-running operations. Returns a Spinner instance that can be used as a context manager or controlled manually.

Context manager usage:

with tui.spinner("Processing"):
    do_work()

Manual usage:

spinner = tui.spinner("Processing")
spinner.start()
do_work()
spinner.succeed("Done!")

Spinner methods:

  • start(): Begin animation
  • stop(status="success", final_message=None): Stop and show status
  • succeed(message=None): Stop with success status
  • fail(message=None): Stop with error status
  • warn(message=None): Stop with warning status

step(title: str)

Context manager for build steps:

with tui.step("Compiling"):
    run_compiler()

License

MIT License. See LICENSE for details.

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

tuiro-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

tuiro-0.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file tuiro-0.1.1.tar.gz.

File metadata

  • Download URL: tuiro-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for tuiro-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6dc598518a29343c91d9fb96e25b60c01c9f7c5f0a8756a48560d69234337c25
MD5 cec2468be4ea16c7c4a1bb09ed624f96
BLAKE2b-256 125429c5e6ab7b9162d33aede17e44bbcc895be19fbbf1c82e50c129b8e94b67

See more details on using hashes here.

File details

Details for the file tuiro-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tuiro-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for tuiro-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3aebf84edab48cd9cd55eb4435b7476ae6fc70d8e695d1de5ad1ac7fc8efac7f
MD5 61ad026be2589f6c81c9b845a6b292af
BLAKE2b-256 10a787ce670c3dfe303f8c947bd987113cfff4973f7cdb197002b1d2f7498581

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