clihelp 0.1.0

Shared colored --help rendering + --color=<WHEN> resolution for the fast* CLI toolkit
Documentation
  • Coverage
  • 44.74%
    17 out of 38 items documented1 out of 24 items with examples
  • Size
  • Source code size: 48.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 540.55 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • CallMeAlphabet/clihelp
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CallMeAlphabet

clihelp

The colored --help renderer shared by the fast* utils, extracted after all of them independently reinvented the same Row/Section/paint help page.

Usage

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);

ColorWhen also resolves the -L/--color <auto|always|never> flag pattern shared by these tools:

let color = clihelp::ColorWhen::parse(&flag_value)?.resolve();

For output that doesn't fit the flag-table model, free-form prose sections, or coloring numbers outside the help page entirely; clihelp::header() and clihelp::paint() expose the same palette directly.

Install

[dependencies]
clihelp = "0.1"

License

GPL-3.0-or-later, matching the tools that use it.