Skip to main content

DefaultHelpFormatter

Struct DefaultHelpFormatter 

Source
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§

Source§

impl DefaultHelpFormatter

Source

pub fn new() -> Self

Create a new DefaultHelpFormatter.

Trait Implementations§

Source§

impl Debug for DefaultHelpFormatter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DefaultHelpFormatter

Source§

fn default() -> DefaultHelpFormatter

Returns the “default value” for a type. Read more
Source§

impl HelpFormatter for DefaultHelpFormatter

Source§

fn format_app(&self, config: &CommandsConfig) -> String

Format the application-level help (list of all commands).

§Output structure
myapp 1.0.0

USAGE:
    myapp <command> [arguments] [options]

COMMANDS:
    hello      Say hello to someone
    process    Process data files

Run 'myapp --help <command>' for more information on a command.
Source§

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:
    hi

If the command is not found, returns a message listing available commands.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.