Skip to main content

Module util

Module util 

Source
Expand description

Small formatting/parsing helpers shared by the other modules.

Constants§

GLYPH_FAIL
✕
GLYPH_INFO
◆
GLYPH_PASS
✓
GLYPH_WARN
▲

Functions§

dim
Dimmed — labels, legends, secondary detail.
error_block
One failure rendered in the tool’s visual language: a red ✕ line, the message’s own continuation lines indented beneath it, then any anyhow causes as dim rows. Plain glyphs when colors are off.
fail
Red — failures.
force_remove_dir
Remove a tree robustly: read-only files (a wrapper’s store, copies that inherited the read-only attribute) block remove_dir_all on Windows, so clear the flag and retry once; report the original error if it still fails.
green
Brand-green text (#92D293) — section titles and success accents.
heading
Bold brand green — top-level headings.
human_age
Age of a timestamp, human-readable (“3.4 days”).
human_bytes
1234567 -> "1.2 MiB" style, compact.
human_duration
Compact duration for humans (“3.4 s”, “1.2 min”, “2.1 h”).
info
Calm blue — neutral info.
on_path
Is program reachable through PATH? (bare which, no extra crate)
parse_duration
Parse "30d", "2w", "12h", "90m", "45s" or plain seconds "45".
warn
Amber — warnings.
which
Is program installed at all (PATH or cargo bin dir)?
which_path
Absolute path of program if discoverable — first on PATH, then as a fallback in Cargo’s own bin dir ($CARGO_HOME/bin, e.g. C:\Users\<user>\.cargo\bin), which rustup tools live in but isn’t on PATH in every shell. Returns None when not found anywhere.