[][src]Struct kern::cli::Command

pub struct Command<'a> { /* fields omitted */ }

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

impl<'a> Clone for Command<'a>[src]

impl<'a> Debug for Command<'a>[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.