Skip to main content

render_help

Function render_help 

Source
pub fn render_help(command: &Command) -> String
Expand description

Render a human-readable help page for a command.

The output contains the following sections (each omitted when empty): NAME, SUMMARY, DESCRIPTION, USAGE, ARGUMENTS, FLAGS, SUBCOMMANDS, EXAMPLES, BEST PRACTICES, ANTI-PATTERNS.

§Arguments

  • command — The command to render help for.

§Examples

let cmd = Command::builder("greet")
    .summary("Say hello")
    .build()
    .unwrap();

let help = render_help(&cmd);
assert!(help.contains("NAME"));
assert!(help.contains("greet"));
assert!(help.contains("SUMMARY"));