pub struct Printer { /* private fields */ }Expand description
An object which you can configure to print the help of a command
Implementations§
source§impl Printer
impl Printer
sourcepub fn new(cmd: Command) -> Self
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);
}sourcepub fn make_skin() -> MadSkin
pub fn make_skin() -> MadSkin
Build a skin for the detected theme of the terminal (i.e. dark, light, or other)
sourcepub fn skin_mut(&mut self) -> &mut MadSkin
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
sourcepub fn with_introduction(self, intro: &'static str) -> Self
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);
}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);
}pub fn expander_mut(&mut self) -> &mut OwningTemplateExpander<'static>
pub fn print_template(&self, template: &str)
sourcepub fn print_help(&self)
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§
impl RefUnwindSafe for Printer
impl Send for Printer
impl Sync for Printer
impl Unpin for Printer
impl UnwindSafe for Printer
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