Expand description
clihelp — the --help renderer that fasthex, fastwc, fastcp, and
fastcount all independently reinvented.
Extracted verbatim in spirit (same colors, same column alignment) from
fasthex’s main.rs, just parameterized so four crates can share one copy.
use clihelp::{ColorWhen, HelpPage, Row, Section};
let page = HelpPage::new("fasthex 0.3.0 - a very fast hex dumper")
.usage("fasthex [options] [file]...")
.usage("fasthex -r [options] [file] [-j <offset>]")
.blurb("Multiple files are concatenated and treated as one stream.")
.section(Section::with_note(
"OUTPUT FORMAT",
"Rule: lowercase = one-byte mode, UPPERCASE = two-byte mode.",
vec![
Row::new("", "(default)", "canonical hex + ASCII display"),
Row::new("-x", "--hex", "one-byte hexadecimal display"),
],
))
.section(Section::new(
"LAYOUT",
vec![Row::with_value("-W", "--width", "<N>", "bytes per row (default: 16)")],
));
page.print(ColorWhen::Auto);Structs§
- Help
Page - A full
--helppage: a name/version line, usage line(s), an optional blurb, a list ofSections, and an optional footer (e.g. fasthex’s size-suffix legend). - Row
- A single flag row, e.g.
-W, --width <N> bytes per row (default: 16). - Section
- A titled group of
Rows, e.g.LAYOUTorOFFSET & NAVIGATION. - Theme
- ANSI palette for a help page. Defaults match the look shared across fasthex / fastwc / fastcp / fastcount; override if a tool wants to diverge.
Enums§
- Color
When - When to emit ANSI color, mirroring the
-L/--color <WHEN>flag shared by fasthex and fastcount.
Functions§
- header
- Color a standalone section header, e.g. fastcp’s hand-written
NOTESblock that doesn’t fit theRow/Sectiontable model. Uses the defaultTheme; callTheme::header_textdirectly if you need a custom palette. - paint
- Wrap
sincolor(an ANSI escape prefix, e.g.Theme::flag) whenon, resetting afterward. For coloring output outside the help page itself — e.g. fastcount’s colored benchmark numbers, which want the same bold-cyan the flag table uses but aren’t rendering aRow.