Trait arrrg::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) -> ! { ... }
}
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.

Implementors§