Skip to main content

Module help

Module help 

Source
Available on crate feature help only.
Expand description

Styled help extracted from Clap and rendered as a semantic document.

App prints help for you. These functions serve a CLI that drives its own lifecycle. document turns a Clap command into a Document, and the try_emit functions print it when the arguments ask for help. Help uses the same renderer, theme, and width policy as command output.

use clap::Parser;
use ctl_core::help::document;

#[derive(Parser)]
#[command(name = "toy", about = "A toy")]
struct Cli {}

let help = document(<Cli as clap::CommandFactory>::command());
assert!(!help.is_empty());

Functions§

document
Build the help document of a Clap command.
emit_bare_with_options
Print the root command’s help to stderr, as shown for a bare invocation of a command that requires input.
try_emit
Print styled help to stdout when the process argv asks for it, and return true. Return false and print nothing otherwise.
try_emit_from
Like try_emit, reading args in place of the process argv. The first item is the binary name.
try_emit_from_with_options
Like try_emit, reading args and rendering with options.
try_emit_with_options
Like try_emit, rendering with options in place of the defaults.