Trait CLI

Source
pub trait CLI: Sized {
    // Required method
    fn parse(args: impl Iterator<Item = String>) -> Result<Parse<Self>, Error>;

    // Provided method
    fn process() -> Self { ... }
}

Required Methods§

Source

fn parse(args: impl Iterator<Item = String>) -> Result<Parse<Self>, Error>

Parses the arguments as a command-line interface of the current type, returning errors as a value for manul handling.

If you don’t need fine control over program flow, use CLI::processs instead.

Provided Methods§

Source

fn process() -> Self

Parses std::env::args() as a command-line interface of the current type.

If an error occurs while parsing, it will be send to stderr and the process will exit. If the user enters --help or -h, help info will be sent to stderr and the process will exit.

If you want finer control over program flow, use CLI::parse instead.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§