Skip to main content

Crate jt_consoleutils

Crate jt_consoleutils 

Source
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

ModuleWhat it provides
outputoutput::Output trait, output::ConsoleOutput, output::StringOutput, output::OutputMode
shellshell::Shell trait, shell::ProcessShell, shell::DryRunShell, shell::MockShell
colorizeRainbow ANSI colorizer
colorsANSI escape-code constants
helpHelp / version printing helpers
terminalTerminal width detection
str_utilsHuman-readable byte formatting and other string helpers
fs_utilsFilesystem comparison and permission helpers
versionBuild-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::Output trait and its standard implementations. The Output trait and its standard implementations.
shell
The shell::Shell trait and its standard implementations. The Shell trait 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.