unilang_help 0.2.0

Reusable help-page domain model, verbosity levels, and renderers for unilang-style CLIs.
docs.rs failed to build unilang_help-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

unilang_help

Reusable help-page domain model, verbosity levels, and renderers for unilang-style CLIs.

Why a separate crate

Help rendering has no reason to depend on a command framework's type system. This crate defines a small, pre-rendered-string data model — the producing side (for example unilang's help adapter) converts its own command definitions into that model once, and every renderer here consumes it unchanged. Any CLI that can describe a command as strings can reuse the renderers.

Components

Component Purpose
HelpCommandData / HelpParamData Renderer-independent help data for one command and its parameters
HelpVerbosity Five detail levels, Minimal (0) to Comprehensive (4); default Standard (2); reads UNILANG_HELP_VERBOSITY
HelpDisplayOptions Global visibility toggles (version, status, aliases, tags); reads UNILANG_HELP_HIDE_VERSION
PlainRenderer Plain-text command pages at all five verbosity levels, plus a parameter detail page
CliFmtRenderer Column-aligned, colour-aware command and parameter pages via cli_fmt; mandatory whenever the crate is enabled

The PlainRenderer command-page formats are a line-faithful port of the original unilang HelpGenerator output — consumers migrating from that implementation get byte-identical text for the same data.

Example

use unilang_help::{ HelpCommandData, HelpParamData, HelpVerbosity, PlainRenderer };

let mut param = HelpParamData::default();
param.name = "scope".into();
param.kind = "Enum".into();
param.kind_compact = "enum".into();
param.description = "Discovery strategy selector.".into();
param.optional = true;
param.choices = vec![ "local".into(), "global".into() ];

let mut cmd = HelpCommandData::default();
cmd.name = ".rollup".into();
cmd.description = "Aggregate readme files.".into();
cmd.params.push( param );

let renderer = PlainRenderer::default().with_verbosity( HelpVerbosity::Basic );
let page = renderer.render( &cmd );
assert!( page.contains( ".rollup - Aggregate readme files." ) );
assert!( page.contains( "  scope::enum" ) );

Parameter detail pages are rendered from the same data:

use unilang_help::{ HelpCommandData, HelpParamData, PlainRenderer };

let mut param = HelpParamData::default();
param.name = "scope".into();
param.kind = "Enum".into();
param.kind_compact = "enum".into();
param.choices = vec![ "local".into(), "global".into() ];

let mut cmd = HelpCommandData::default();
cmd.name = ".rollup".into();

let page = PlainRenderer::default().render_param( &cmd, &param );
assert!( page.contains( "Parameter: scope" ) );
assert!( page.contains( "Choices: local, global" ) );

Features

Feature Default Purpose
enabled yes Core model, verbosity, PlainRenderer, and CliFmtRenderer (backed by cli_fmt's detail-page template) — a single master switch, no partial configuration
full Alias for enabled, kept for cross-crate consistency

cli_fmt is a mandatory dependency of this crate: there is no plain-text-only configuration that excludes CliFmtRenderer. PlainRenderer remains available alongside it as a lighter-weight rendering choice, not as a way to opt out of the cli_fmt dependency itself.

Environment variables

Variable Effect
UNILANG_HELP_VERBOSITY=0..4 Selects the verbosity level (HelpVerbosity::from_env)
UNILANG_HELP_HIDE_VERSION=1 Hides version lines globally (HelpDisplayOptions::with_env_overrides)