Struct clap_help::Printer

source ·
pub struct Printer { /* private fields */ }
Expand description

An object which you can configure to print the help of a command

Implementations§

source§

impl Printer

source

pub fn new(cmd: Command) -> Self

Examples found in repository?
examples/area/main.rs (line 55)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn main() {
    let args = Args::parse();

    if args.help {
        Printer::new(Args::command())
            .with_introduction(INTRO)
            .show_author(false)
            .print_help();
        return;
    }

    let (w, h) = (args.width, args.height);
    println!("Computation strategy: {:?}", args.strategy);
    println!("{w} x {h} = {}", w*h);
}
source

pub fn make_skin() -> MadSkin

Build a skin for the detected theme of the terminal (i.e. dark, light, or other)

source

pub fn with_skin(self, skin: MadSkin) -> Self

Use the provided skin

source

pub fn skin_mut(&mut self) -> &mut MadSkin

Give a mutable reference to the current skin (by default the automatically selected one) so that it can be modified

source

pub fn with_introduction(self, intro: &'static str) -> Self

Set the introduction text, interpreted as Markdown

Examples found in repository?
examples/area/main.rs (line 56)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn main() {
    let args = Args::parse();

    if args.help {
        Printer::new(Args::command())
            .with_introduction(INTRO)
            .show_author(false)
            .print_help();
        return;
    }

    let (w, h) = (args.width, args.height);
    println!("Computation strategy: {:?}", args.strategy);
    println!("{w} x {h} = {}", w*h);
}
source

pub fn show_author(self, b: bool) -> Self

Set whether to display the application author (default is true)

Examples found in repository?
examples/area/main.rs (line 57)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn main() {
    let args = Args::parse();

    if args.help {
        Printer::new(Args::command())
            .with_introduction(INTRO)
            .show_author(false)
            .print_help();
        return;
    }

    let (w, h) = (args.width, args.height);
    println!("Computation strategy: {:?}", args.strategy);
    println!("{w} x {h} = {}", w*h);
}
source

pub fn expander_mut(&mut self) -> &mut OwningTemplateExpander<'static>

source

pub fn print_template(&self, template: &str)

source

pub fn print_help(&self)

Print the whole help: title, author, introduction, usage, and options

To print only some parts, or to use custom templates, use print_template instead.

Examples found in repository?
examples/area/main.rs (line 58)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn main() {
    let args = Args::parse();

    if args.help {
        Printer::new(Args::command())
            .with_introduction(INTRO)
            .show_author(false)
            .print_help();
        return;
    }

    let (w, h) = (args.width, args.height);
    println!("Computation strategy: {:?}", args.strategy);
    println!("{w} x {h} = {}", w*h);
}

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.