pub struct Help {
pub usage: &'static str,
pub docs: &'static [&'static str],
pub switches: &'static [Switch],
}
Expand description
Helper that can be formatted into documentation text.
Fields§
§usage: &'static str
The verbatim usage summary specified when invoking the macro.
docs: &'static [&'static str]
Documentation comments associated with the command.
switches: &'static [Switch]
Switches associated with the command.
Implementations§
source§impl Help
impl Help
sourcepub fn format(&self) -> HelpFormat<'_>
pub fn format(&self) -> HelpFormat<'_>
Format the help with the given config.
Examples
argwerk::define! {
/// A simple test command.
#[usage = "command [-h]"]
struct Args {
help: bool,
}
/// Prints the help.
///
/// This includes:
/// * All the available switches.
/// * All the available positional arguments.
/// * Whatever else the developer decided to put in here! We even support wrapping comments which are overly long.
["-h" | "--help"] => {
help = true;
}
}
let formatted = format!("{}", Args::help().format().width(120));
assert!(formatted.split('\n').any(|line| line.len() > 80));
assert!(formatted.split('\n').all(|line| line.len() < 120));