Trait CommandLine

Source
pub trait CommandLine:
    Sized
    + Default
    + Eq
    + PartialEq {
    // Required methods
    fn add_opts(&self, prefix: Option<&str>, opts: &mut Options);
    fn matches(&mut self, prefix: Option<&str>, matches: &Matches);
    fn canonical_command_line(&self, prefix: Option<&str>) -> Vec<String>;

    // Provided methods
    fn from_command_line(usage: &str) -> (Self, Vec<String>) { ... }
    fn from_command_line_relaxed(usage: &str) -> (Self, Vec<String>) { ... }
    fn from_arguments(usage: &str, args: &[&str]) -> (Self, Vec<String>) { ... }
    fn from_arguments_relaxed(usage: &str, args: &[&str]) -> (Self, Vec<String>) { ... }
    fn usage(&mut self, opts: Options, brief: &str) { ... }
    fn error(&mut self, msg: impl AsRef<str>) { ... }
    fn exit(&mut self, status: i32) { ... }
}
Expand description

CommandLine creates a command line parser for anyone who implements CommandLine::add_opts, CommandLine::matches and CommandLine::canonical_command_line. This is a wrapper around getopts to tie together options and matches.

Required Methods§

Source

fn add_opts(&self, prefix: Option<&str>, opts: &mut Options)

Add options to the getopts parser.

Source

fn matches(&mut self, prefix: Option<&str>, matches: &Matches)

Assign values to self using the provided getopts matches.

Source

fn canonical_command_line(&self, prefix: Option<&str>) -> Vec<String>

Return the canonical command line for this CommandLine.

Provided Methods§

Source

fn from_command_line(usage: &str) -> (Self, Vec<String>)

Parse from the command line. This function will panic if a non-canonical command line is provided.

Source

fn from_command_line_relaxed(usage: &str) -> (Self, Vec<String>)

Parse from the command line. This function will allow a non-canonical command line to execute.

Source

fn from_arguments(usage: &str, args: &[&str]) -> (Self, Vec<String>)

Parse from the provided arguments. This function will panic if a non-canonical command line is provided.

Source

fn from_arguments_relaxed(usage: &str, args: &[&str]) -> (Self, Vec<String>)

Parse from the provided arguments. This function will allow a non-canonical command line to execute.

Source

fn usage(&mut self, opts: Options, brief: &str)

Display the usage and exit 1.

Source

fn error(&mut self, msg: impl AsRef<str>)

Report an error.

Source

fn exit(&mut self, status: i32)

Exit with the provided status.

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§