[−][src]Struct kern::cli::Command
Command represents an command parsed from the command-line
Example
use kern::Command; use std::env; let args: Vec<String> = env::args().collect(); let command = Command::from(&args, &["option"]);
Methods
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]
Create a new Command from raw command line arguments without options
pub fn from(raw: &'a [String], filter_options: &[&str]) -> Self
[src]
Create a new Command from raw command line arguments Provide the arguments list as &[&str]
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Command<'a>
impl<'a> Send for Command<'a>
impl<'a> Sync for Command<'a>
impl<'a> Unpin for Command<'a>
impl<'a> UnwindSafe for Command<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,