pub struct DefaultHelpFormatter;Expand description
Default help formatter — colored, aligned, English-only output.
Outputs English text to the terminal. If you need another language,
implement HelpFormatter and supply it via
CliBuilder::help_formatter().
Uses the colored crate for terminal output. Colours are applied
automatically and disabled when the terminal does not support them.
Column widths are computed dynamically so that descriptions are aligned regardless of command or argument name lengths.
§Example
use dynamic_cli::help::DefaultHelpFormatter;
let fmt = DefaultHelpFormatter::new();
// or equivalently:
let fmt = DefaultHelpFormatter::default();Implementations§
Trait Implementations§
Source§impl Debug for DefaultHelpFormatter
impl Debug for DefaultHelpFormatter
Source§impl Default for DefaultHelpFormatter
impl Default for DefaultHelpFormatter
Source§impl HelpFormatter for DefaultHelpFormatter
impl HelpFormatter for DefaultHelpFormatter
Source§fn format_app(&self, config: &CommandsConfig) -> String
fn format_app(&self, config: &CommandsConfig) -> String
Format the application-level help (list of all commands).
§Output structure
myapp 1.0.0
USAGE:
<command> [arguments] [options]
COMMANDS:
hello Say hello to someone
process Process data filesThe output is the same in CLI and REPL mode. How to ask for the help of one command differs between them, so the interface appends that line itself.
Source§fn format_command(&self, config: &CommandsConfig, command: &str) -> String
fn format_command(&self, config: &CommandsConfig, command: &str) -> String
Format help for a single command, looked up by name or alias.
§Output structure
hello — Say hello to someone
USAGE:
hello <name> [options]
ARGUMENTS:
name (string, required) Name to greet
OPTIONS:
-l, --loud (bool) Use uppercase
ALIASES:
hiIf the command is not found, returns a message listing available commands.
Source§fn format_directives(&self, directives: &[DirectiveDefinition]) -> String
fn format_directives(&self, directives: &[DirectiveDefinition]) -> String
Format the list of REPL directives, in the layout of the default trait implementation with colours.
§Output structure
DIRECTIVES:
:help [command] Show the application help, or the help of a command [aliases: :h, :?]
:load <path> Run every line of a script file
:quit Save the session history and leave [aliases: :q]
:exit Leave without saving the session historyAuto Trait Implementations§
impl Freeze for DefaultHelpFormatter
impl RefUnwindSafe for DefaultHelpFormatter
impl Send for DefaultHelpFormatter
impl Sync for DefaultHelpFormatter
impl Unpin for DefaultHelpFormatter
impl UnsafeUnpin for DefaultHelpFormatter
impl UnwindSafe for DefaultHelpFormatter
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more