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§
Sourcefn add_opts(&self, prefix: Option<&str>, opts: &mut Options)
fn add_opts(&self, prefix: Option<&str>, opts: &mut Options)
Add options to the getopts parser.
Sourcefn matches(&mut self, prefix: Option<&str>, matches: &Matches)
fn matches(&mut self, prefix: Option<&str>, matches: &Matches)
Assign values to self using the provided getopts matches.
Sourcefn canonical_command_line(&self, prefix: Option<&str>) -> Vec<String>
fn canonical_command_line(&self, prefix: Option<&str>) -> Vec<String>
Return the canonical command line for this CommandLine.
Provided Methods§
Sourcefn from_command_line(usage: &str) -> (Self, Vec<String>)
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.
Sourcefn from_command_line_relaxed(usage: &str) -> (Self, Vec<String>)
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.
Sourcefn from_arguments(usage: &str, args: &[&str]) -> (Self, Vec<String>)
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.
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.