[][src]Struct dia_args::ReadOnlyArgs

pub struct ReadOnlyArgs { /* fields omitted */ }

Read-only Args

This struct is simply a read-only wrapper of Args.

Methods

impl ReadOnlyArgs[src]

pub const fn new(args: Args) -> Self[src]

Methods from Deref<Target = Args>

pub fn cmd(&self) -> Option<&str>[src]

pub fn cmds(&self) -> Option<Vec<&str>>[src]

Gets the commands

If it's some vector, the vector is not empty.

pub fn args(&self) -> &HashMap<String, Vec<String>>[src]

pub fn sub_args(&self) -> Option<Vec<&str>>[src]

Sub arguments

If it's some vector, the vector is not empty.

pub fn is_empty(&self) -> bool[src]

pub fn has_args(&self) -> bool[src]

pub fn use_stdin(&self) -> bool[src]

pub fn get<T, S>(&self, keys: &[S]) -> Result<Option<T>> where
    T: FromStr,
    S: AsRef<str>, 
[src]

Gets a value

You can provide multiple keys as you want. But the user can only provide one single key of them. This function can be used for short version and long version of your keys.

Examples

use dia_args;

let args = dia_args::parse_strings(["--type", "ogg"].into_iter())?;
assert_eq!(args.get::<String, _>(&["-t", "--type"])?.unwrap(), "ogg");

let args = dia_args::parse_strings(["--type", "ogg"].into_iter())?;
assert!(args.get::<String, _>(&["-t"])?.is_none());

let args = dia_args::parse_strings(["--type", "ogg", "-t", "some"].into_iter())?;
args.get::<String, _>(&["-t", "--type"]).unwrap_err();

pub fn get_vec<T, S>(&self, keys: &[S]) -> Result<Option<Vec<T>>> where
    T: FromStr,
    S: AsRef<str>, 
[src]

Gets a vector of values

Examples

use dia_args;

let args = dia_args::parse_strings(
    ["--type", "ogg", "-t", "m4v", "--type", "md", "-t", "rs"].into_iter()
)?;
let mut types = args.get_vec::<String, _>(&["-t", "--type"])?.unwrap();
types.sort();
assert_eq!(types, &["m4v", "md", "ogg", "rs"]);

Trait Implementations

impl Clone for ReadOnlyArgs[src]

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

Performs copy-assignment from source. Read more

impl From<Args> for ReadOnlyArgs[src]

impl Deref for ReadOnlyArgs[src]

type Target = Args

The resulting type after dereferencing.

impl Debug for ReadOnlyArgs[src]

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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