Skip to main content

Crate clihelp

Crate clihelp 

Source
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§

HelpPage
A full --help page: a name/version line, usage line(s), an optional blurb, a list of Sections, 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. LAYOUT or OFFSET & 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§

ColorWhen
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 NOTES block that doesn’t fit the Row/Section table model. Uses the default Theme; call Theme::header_text directly if you need a custom palette.
paint
Wrap s in color (an ANSI escape prefix, e.g. Theme::flag) when on, 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 a Row.