[−][src]Struct dia_args::ReadOnlyArgs
Methods
impl ReadOnlyArgs
[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]
T: FromStr,
S: AsRef<str>,
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]
T: FromStr,
S: AsRef<str>,
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(&self) -> 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]
impl Debug for ReadOnlyArgs
[src]
Auto Trait Implementations
impl Send for ReadOnlyArgs
impl Sync for ReadOnlyArgs
Blanket Implementations
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,