[−][src]Struct dia_args::ReadOnlyArgs
Methods
impl ReadOnlyArgs
[src]
Methods from Deref<Target = Args>
pub fn cmd(&self) -> Option<&str>
[src]
Gets the command
This is simply the first one of args()
.
pub fn args(&self) -> Option<Vec<&str>>
[src]
Gets arguments
If it's some vector, the vector is not empty.
The first one can be used as a command, via cmd()
.
pub fn options(&self) -> &HashMap<String, Vec<String>>
[src]
Gets raw options
Normally you don't need this. Instead, you can use get()
, get_vec()
...
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 use_stdin(&self) -> bool
[src]
pub fn get<T>(&self, keys: &[&str]) -> Result<Option<T>> where
T: FromStr,
<T as FromStr>::Err: Debug,
[src]
T: FromStr,
<T as FromStr>::Err: Debug,
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"].iter())?; assert_eq!(args.get::<String>(&["-t", "--type"])?.unwrap(), "ogg"); let args = dia_args::parse_strings(["--type", "ogg"].iter())?; assert!(args.get::<String>(&["-t"])?.is_none()); let args = dia_args::parse_strings(["--type", "ogg", "-t", "some"].iter())?; args.get::<String>(&["-t", "--type"]).unwrap_err();
pub fn get_vec<T>(&self, keys: &[&str]) -> Result<Option<Vec<T>>> where
T: FromStr,
<T as FromStr>::Err: Debug,
[src]
T: FromStr,
<T as FromStr>::Err: Debug,
Gets a vector of values
Examples
use dia_args; let args = dia_args::parse_strings( ["--type", "ogg", "-t", "m4v", "--type", "md", "-t", "rs"].iter() )?; let mut types = args.get_vec::<String>(&["-t", "--type"])?.unwrap(); types.sort(); assert_eq!(types, &["m4v", "md", "ogg", "rs"]);
Trait Implementations
impl From<Args> for ReadOnlyArgs
[src]
impl Clone for ReadOnlyArgs
[src]
fn clone(&self) -> ReadOnlyArgs
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Deref for ReadOnlyArgs
[src]
impl Debug for ReadOnlyArgs
[src]
Auto Trait Implementations
impl Send for ReadOnlyArgs
impl Sync for ReadOnlyArgs
impl Unpin for ReadOnlyArgs
impl UnwindSafe for ReadOnlyArgs
impl RefUnwindSafe for ReadOnlyArgs
Blanket Implementations
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 = !
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> 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,