Expand description
Console and shell utilities for Rust CLI tools.
jt-consoleutils provides a set of composable building blocks used across
CLI tools in the jt-* ecosystem. Everything is designed to be testable:
traits with mock/test implementations are provided for every abstraction
that touches I/O or process execution.
§Modules at a glance
| Module | What it provides |
|---|---|
output | output::Output trait, output::ConsoleOutput, output::StringOutput, output::OutputMode |
shell | shell::Shell trait, shell::ProcessShell, shell::DryRunShell, shell::MockShell |
colorize | Rainbow ANSI colorizer |
colors | ANSI escape-code constants |
help | Help / version printing helpers |
terminal | Terminal width detection |
str_utils | Human-readable byte formatting and other string helpers |
fs_utils | Filesystem comparison and permission helpers |
version | Build-info version string formatter |
build_support (feature build-support) | build.rs helper that emits BUILD_DATE / GIT_HASH |
§Quick start — output
use jt_consoleutils::output::{ConsoleOutput, Output, OutputMode};
let mode = OutputMode { verbose: false, quiet: false, dry_run: false };
let mut out = ConsoleOutput::new(mode);
out.writeln("Hello, world!");§Quick start — shell
use jt_consoleutils::shell;
use jt_consoleutils::output::{StringOutput, OutputMode};
let mode = OutputMode::default();
let sh = shell::create(/*dry_run=*/ false);
// sh is a Box<dyn Shell> backed by ProcessShell.Modules§
- colorize
- Rainbow ANSI colorizer for terminal output. Helpers to colorize text with a left-to-right rainbow.
- colors
- Raw ANSI escape-code constants (
RESET,BOLD,RED, etc.). Raw ANSI escape-code constants for terminal text styling. - fs_
utils - Filesystem helpers: path comparison, permission bits, symlink removal.
- help
- Help and version printing helpers for CLI entry points. Help and version printing helpers for CLI tools.
- output
- The
output::Outputtrait and its standard implementations. TheOutputtrait and its standard implementations. - shell
- The
shell::Shelltrait and its standard implementations. TheShelltrait and its standard implementations. - str_
utils - String formatting helpers: byte counts, plurals, path conversion.
- terminal
- Terminal introspection helpers (e.g. column width).
- version
- Build-info version string formatter.