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));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Help
impl RefUnwindSafe for Help
impl Send for Help
impl Sync for Help
impl Unpin for Help
impl UnwindSafe for Help
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more