Skip to main content

R3CLI

CI

R3CLI is the shared command-line presentation layer for R3Neer's tools.

It provides one visual language and one help model across Python, PowerShell and Nushell without turning presentation into the source of truth for program data.

product/domain code
       │
       ├── structured data / machine channel
       │
       └── semantic presentation calls
                    │
                    ▼
                  R3CLI
          ┌─────────┼─────────┐
          ▼         ▼         ▼
        Python   PowerShell  Nushell

The design originated in ModpackTools and was extracted so other tools can reuse the same hierarchy, colour semantics, symbols, wrapping and help behaviour without copying UI code.

Design goals

R3CLI is deliberately small. It is responsible for:

  • optional banners, headings, sections and readable spacing;
  • semantic status messages;
  • key/value layouts and compact tables;
  • consistent symbols with ASCII fallbacks;
  • colour policy, including auto, always, never and NO_COLOR;
  • deterministic wrapping against terminal width;
  • expected CLI error presentation;
  • one validated catalogue model for generated help;
  • equivalent PowerShell and Nushell adapters built from the same canonical resources.

R3CLI is not a domain framework, command router, persistence layer or machine-output format. Products keep those responsibilities themselves.

Human rendering should remain separable from structured program output.

Visual language

The default theme uses semantic roles rather than product-specific hard-coded colours:

structure / headings    cyan
process / actions       orange
secondary context       quiet neutral
values                  primary value colour
success                 green + symbol
warning                 orange + symbol
error                   red + symbol

Colour is never the only signal. Status meaning is paired with symbols, and every renderer can fall back to ASCII.

See docs/design-language.md for the full visual contract.

Python quick start

Install the package in a development checkout:

python -m pip install -e ".[test]"

Then use semantic UI operations:

from r3_cli import ConsoleUI

ui = ConsoleUI()
ui.step("Reading the project")
ui.success("Project is ready.")

The public Python package also exposes the shared help and error models:

from r3_cli import (
    CliError,
    ColourMode,
    CommandHelp,
    ConsoleUI,
    HelpCatalogue,
    HelpItem,
    HelpRequest,
    R3ArgumentParser,
    Theme,
    add_output_arguments,
    compose_theme,
    load_help_catalogue,
    load_theme,
    resolve_help_request,
    validate_argparse_catalogue,
)

R3ArgumentParser and add_output_arguments integrate the presentation policy with argparse without requiring product code to hand-format standard output controls.

UI primitives

The adapters expose the same conceptual vocabulary even where host-language syntax differs.

Common primitives include:

  • banner;
  • heading;
  • section;
  • status / semantic success, warning and error presentation;
  • line with semantic segments;
  • key-value;
  • table;
  • symbol lookup;
  • help catalogue validation and rendering.

The intent is semantic composition. Product code says what a fragment means; the renderer decides how that role is represented in colour, ASCII/Unicode and available terminal width.

Help from one catalogue

R3CLI can render a ModpackTools-style command overview and focused command pages from one validated catalogue.

A catalogue describes:

  • product name and description;
  • invocation;
  • group order;
  • commands and summaries;
  • usage forms;
  • global and command-specific items;
  • notes;
  • examples;
  • help options.

The same catalogue can therefore drive overview help, focused help and contract tests instead of maintaining separate prose fragments for each renderer.

See:

Nushell adapter

R3CLI includes an official native Nushell adapter for Nu 0.115+.

use ./nushell/r3cli

let ui = (r3cli console --colour auto)
r3cli status $ui step 'Reading project'
r3cli key-value $ui 'Version' '1.0.0'

The adapter does not require Python at runtime. Canonical colours and symbols are packaged into deterministic adapter resources.

Automatic colour detection is evaluated at the final emission boundary so collected intermediate expressions do not accidentally look redirected and disable colour. CI includes pseudo-terminal coverage for that behaviour.

The console can also receive an explicit sink, terminal state, width, ASCII mode and theme extension, making product integration and deterministic tests possible without rewriting rendering code.

See docs/nushell.md.

PowerShell adapter

The PowerShell adapter exposes the same visual language as a module and likewise requires no Python runtime after packaging.

Products can vendor the generated distribution and import it privately instead of requiring users to install R3CLI as a separate global module.

See docs/powershell.md.

Building shell distributions

The repository keeps canonical implementation resources under Python source and provides deterministic adapter builders:

python scripts/build_powershell.py --output <directory>
python scripts/build_nushell.py --output <directory>

This supports a dependency model used by projects such as ModpackTools and Show-Tree:

R3CLI source revision
       │
       ├── build PowerShell adapter
       ├── build Nushell adapter
       ▼
product/vendor/R3CLI
       │
       └── pin revision + hashes in product dependency manifest

Users of the consuming product then install one self-contained tool. They do not need an independent R3CLI checkout.

Themes

The default theme is canonical. Products may extend it with additional semantic roles for their own domain while preserving the base language.

Python exposes Theme, load_theme and compose_theme. Shell adapters consume the same canonical palette and permit validated extensions appropriate to their host API.

Theme values use semantic names rather than references to a specific command or screen.

Colour and terminal behaviour

R3CLI follows a small predictable contract:

  • auto uses terminal detection and respects NO_COLOR;
  • always forces ANSI colour;
  • never disables it;
  • ASCII mode substitutes canonical ASCII symbols;
  • wrapping uses visible Unicode width rather than raw byte length;
  • non-terminal and captured paths can be controlled explicitly in tests and embedding scenarios.

Machine-readable data belongs outside this renderer. A product that emits JSON should keep that channel clean and route R3CLI's human presentation independently.

Expected errors

Expected CLI failures should be designed, not dumped as implementation exceptions.

R3CLI provides models such as CliError and Diagnostic so products can present stable identifiers, concise messages and actionable context while retaining the distinction between expected user-facing failures and unexpected defects.

Project structure

R3CLI/
├── src/r3_cli/              # canonical Python package and resources
├── powershell/R3CLI/        # PowerShell adapter source/distribution shape
├── nushell/r3cli/           # native Nushell adapter
├── scripts/                 # deterministic adapter builders
├── templates/               # language-neutral catalogue templates
├── docs/                    # design and adapter contracts
└── tests/                   # Python and cross-language regression tests

Development

Install test dependencies in editable mode:

python -m pip install -e ".[test]"

Run Python tests:

pytest

After changing renderers, resources, help contracts or shell adapters, also build and test the PowerShell and Nushell distributions. CI exercises the cross-language contracts and terminal-specific behaviour.

The project currently supports Python 3.11 through 3.14 and targets PowerShell 7 and Nushell 0.115+ for the official shell adapters.

For package build, wheel verification, and PyPI release steps, see docs/python-release.md.

Documentation

Licence

MIT. See LICENSE.

Release files for r3-cli 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for r3-cli 0.5.2
File Size Uploaded
r3_cli-0.5.2.tar.gz 40.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for r3-cli 0.5.2
File Interpreter ABI Platform
r3_cli-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 55.6 kB

Release files / r3_cli-0.5.2.tar.gz

Download URL r3_cli-0.5.2.tar.gz
Size 40.4 kB
Tags Source
SHA-256 checksum
How to use checksums
58e9f211f27995f2e6c208ed374719035fccd64e7ed76af73dba2ec91552e711
BLAKE2b-256 checksum
How to use checksums
c445c99f2c6130174ee08d1c81ba77cace1ae264a371de5fd79599644e1d76b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / r3_cli-0.5.2-py3-none-any.whl

Download URL r3_cli-0.5.2-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0b80d781c71dbedecf0125dc7eb649dd6b2f622762d9f5f39e4923d1732ec10
BLAKE2b-256 checksum
How to use checksums
48112613c7411d549487fa2920a7a0d1c0eaf66876797f89aa823ffea683f537
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page