pub struct HelpFormatter { /* private fields */ }Expand description
HelpFormatter helps print usage information for the Options.
The output format is like:
usage: <cmd_syntax> [opt_usage]
[header]
-<opt>, --<long_opt> <description>
-<opt> <description>
--<long_opt> <description>
-<opt>, --<long_opt>=[opt_name] <description>
[footer]Implementations§
Source§impl HelpFormatter
impl HelpFormatter
Sourcepub fn new(cmd_syntax: &str) -> HelpFormatter
pub fn new(cmd_syntax: &str) -> HelpFormatter
Create a HelpFormatter with default configuration.
The cmd_syntax is typically the name of the executable with positional options.
For example, "cd [<path>]".
Sourcepub fn get_option_comparator(
&self,
) -> Option<&dyn Fn(&AnpOption, &AnpOption) -> Ordering>
pub fn get_option_comparator( &self, ) -> Option<&dyn Fn(&AnpOption, &AnpOption) -> Ordering>
Retrieve the option comparator, which is used to sort the AnpOption
when printing options.
Sourcepub fn get_arg_name(&self) -> &str
pub fn get_arg_name(&self) -> &str
Get the argument name displayed in usage.
Sourcepub fn get_desc_padding(&self) -> usize
pub fn get_desc_padding(&self) -> usize
Get number of padding space for option description.
Sourcepub fn get_left_padding(&self) -> usize
pub fn get_left_padding(&self) -> usize
Get number of padding space before option.
Sourcepub fn get_long_opt_prefix(&self) -> &str
pub fn get_long_opt_prefix(&self) -> &str
Get the long option prefix.
Sourcepub fn get_newline(&self) -> &str
pub fn get_newline(&self) -> &str
Get the newline.
For windows, it defaults to \r\n.
For other operating system, it defaults to \n.
Sourcepub fn get_opt_prefix(&self) -> &str
pub fn get_opt_prefix(&self) -> &str
Get the option prefix.
Sourcepub fn get_syntax_prefix(&self) -> &str
pub fn get_syntax_prefix(&self) -> &str
Get the syntax prefix.
Sourcepub fn set_arg_name(&mut self, arg_name: &str)
pub fn set_arg_name(&mut self, arg_name: &str)
Set the argument name displayed in option usage.
Sourcepub fn set_desc_padding(&mut self, padding: usize)
pub fn set_desc_padding(&mut self, padding: usize)
Set number of padding space for option description.
Sourcepub fn set_left_padding(&mut self, padding: usize)
pub fn set_left_padding(&mut self, padding: usize)
Set number of padding space before option.
Sourcepub fn set_newline(&mut self, newline: &str)
pub fn set_newline(&mut self, newline: &str)
Set the newline characters.
Sourcepub fn set_opt_comparator(
&mut self,
comparator: Option<Box<dyn Fn(&AnpOption, &AnpOption) -> Ordering>>,
)
pub fn set_opt_comparator( &mut self, comparator: Option<Box<dyn Fn(&AnpOption, &AnpOption) -> Ordering>>, )
Set the option comparator, which is used to sort the AnpOption
when printing options.
Sourcepub fn set_syntax_prefix(&mut self, prefix: &str)
pub fn set_syntax_prefix(&mut self, prefix: &str)
Set the syntax prefix, the default value is [DEFAULT_SYNTAX_PREFIX].
Sourcepub fn set_width(&mut self, width: usize)
pub fn set_width(&mut self, width: usize)
Set the maximum width of the display message, which defaults to [DEFAULT_WIDTH].
Sourcepub fn set_cmd_syntax(&mut self, syntax: &str)
pub fn set_cmd_syntax(&mut self, syntax: &str)
Set the cmd syntax, for display purpose only.
The cmd_syntax is typically the name of the executable with positional options.
For example, "cd [<path>]".
Sourcepub fn set_header(&mut self, header: &str)
pub fn set_header(&mut self, header: &str)
Set header message.
Set footer message.
Sourcepub fn set_auto_usage(&mut self, auto_usage: bool)
pub fn set_auto_usage(&mut self, auto_usage: bool)
Set if auto print the option usage after cmd_syntax.
Sourcepub fn print_help<T: Write>(&self, out: &mut T, options: &Options)
pub fn print_help<T: Write>(&self, out: &mut T, options: &Options)
Sourcepub fn print_options<T: Write>(&self, out: &mut T, options: &Options)
pub fn print_options<T: Write>(&self, out: &mut T, options: &Options)
Print detailed information for options only.
Also see HelpFormatter, HelpFormatter::print_help.
Sourcepub fn print_usage<T: Write>(&self, out: &mut T)
pub fn print_usage<T: Write>(&self, out: &mut T)
Print cmd syntax without option usage.
Also see HelpFormatter, HelpFormatter::print_help.
Sourcepub fn print_usage_with_options<T: Write>(&self, out: &mut T, options: &Options)
pub fn print_usage_with_options<T: Write>(&self, out: &mut T, options: &Options)
Print cmd syntax with option usage.
Also see HelpFormatter, HelpFormatter::print_help.
Sourcepub fn render_wrapped_text_block(
&self,
buffer: &mut String,
next_line_tab_stop: usize,
text: &str,
)
pub fn render_wrapped_text_block( &self, buffer: &mut String, next_line_tab_stop: usize, text: &str, )
Render a wrapped text block to the buffer with the max width configured.
When text is wrapped, next_line_tab_stop number of space is appended.