[][src]Struct clipars::Command

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

Command represents an command parsed from the command-line

Example

extern crate clipars;

use clipars::Command;
use std::env;

let env_args = env::args().collect::<Vec<String>>();
let command = Command::from(
    &env_args.iter().map(|s| &**s).collect::<Vec<&str>>()[..],
    &["option1", "option2"],
);

Methods

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

pub fn get_command(&self) -> &'a str[src]

Get command name

pub fn get_parameters(&self) -> &BTreeMap<&'a str, &'a str>[src]

Get all parameters

pub fn get_parameter(&self, name: &'a str) -> Option<&&'a str>[src]

Get specific parameter

pub fn get_options(&self) -> &Vec<&'a str>[src]

Get all options

pub fn is_option(&self, name: &'a str) -> bool[src]

Check if option provided

pub fn get_arguments(&self) -> &Vec<&'a str>[src]

Get all arguments

pub fn get_argument(&self, index: usize) -> Option<&&'a str>[src]

Get argument at specific index

pub fn without_options(raw: &[&'a str]) -> Self[src]

Create a new Command from raw command line arguments without options Provide the arguments list as Vec

extern crate clipars;

use clipars::Command;
use std::env;

let command = Command::without_options(&["command --param=value"]);

pub fn without_command(raw: &[&'a str], filter_options: &[&str]) -> Self[src]

Create a new Command from raw command line arguments without a command name Provide the arguments list as Vec

The command [./command --param1=value1 more args] without the command name is [--param1=value1 more args]

extern crate clipars;

use clipars::Command;
use std::env;

let command = Command::without_command(&["--param=value"], &["option"]);

pub fn without_command_and_options(raw: &[&'a str]) -> Self[src]

Create a new Command from raw command line arguments without a command name and without options Provide the arguments list as Vec

The command [./command --param1=value1 more args] without the command name is [--param1=value1 more args]

extern crate clipars;

use clipars::Command;
use std::env;

let command = Command::without_command_and_options(&["--param=value"]);

pub fn from(raw: &[&'a str], filter_options: &[&str]) -> Self[src]

Create a new Command from raw command line arguments Provide the arguments list as Vec

extern crate clipars;

use clipars::Command;
use std::env;

let command = Command::from(&["command --param=value"], &["option"]);

Trait Implementations

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

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

Auto Trait Implementations

impl<'a> Send for Command<'a>

impl<'a> Sync for Command<'a>

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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

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

The type returned in the event of a conversion error.