Struct argwerk::Help

source ·
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§

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

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.