Struct kern::Command [−][src]
pub struct Command<'a> { /* fields omitted */ }
Command represents a command parsed from the command-line Use CliBuilder to build a parsed Command
Example
use kern::CliBuilder; use std::env; let args: Vec<String> = env::args().collect(); let command = CliBuilder::new().options(&["option"]).build(&args); assert_eq!(command.command().contains("rustdoctest"), true);
Implementations
impl<'a> Command<'a>
[src]
impl<'a> Command<'a>
[src]pub fn command(&self) -> &'a str
[src]
Get command name
pub fn parameters(&self) -> &BTreeMap<&'a str, &'a str>
[src]
Get all parameters
pub fn arguments(&self) -> &Vec<&'a str>
[src]
Get all arguments
pub fn parameter<T: FromStr>(&self, name: &str, default: T) -> T
[src]
Get specific parameter or default
pub fn param(&self, name: &str, default: &'a str) -> &str
[src]
Get specific parameter or default as &str
pub fn options(&self) -> &Vec<&str>
[src]
Get all options
pub fn option(&self, name: &str) -> bool
[src]
Check if option provided
pub fn argument<T: FromStr>(&self, index: usize, default: T) -> T
[src]
Get argument at specific index or default
pub fn arg(&self, index: usize, default: &'a str) -> &str
[src]
Get argument at specific index or default as &str
pub fn without_options(raw: &'a [String]) -> Self
[src]
👎 Deprecated
Create a new Command from raw command line arguments without options
pub fn from(raw: &'a [String], options: &'a [&str]) -> Self
[src]
👎 Deprecated
Create a new Command from raw command line arguments Provide the options list as &&str
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Command<'a>
impl<'a> RefUnwindSafe for Command<'a>
impl<'a> UnwindSafe for Command<'a>
impl<'a> UnwindSafe for Command<'a>