Trait nameless_clap::FromArgMatches[][src]

pub trait FromArgMatches: Sized {
    fn try_from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>;
fn try_update_from_arg_matches(
        &mut self,
        matches: &ArgMatches
    ) -> Result<(), Error>; fn from_arg_matches(matches: &ArgMatches) -> Self { ... }
fn update_from_arg_matches(&mut self, matches: &ArgMatches) { ... } }

Converts an instance of ArgMatches to a consumer defined struct.

Required methods

fn try_from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>[src]

Similar to from_arg_matches, but instead of exiting returns errors via a Result value.

fn try_update_from_arg_matches(
    &mut self,
    matches: &ArgMatches
) -> Result<(), Error>
[src]

Similar to update_from_arg_matches, but instead of exiting returns errors via a Result value.

Loading content...

Provided methods

fn from_arg_matches(matches: &ArgMatches) -> Self[src]

It’s common to have an “application context” struct (sometimes called config) that represents all the normalized values after being processed by the CLI.

For instance, if an application we made had two CLI options, --name <STRING> and a flag --debug to distinguish “debugging mode” for our made up CLI, we may create a context struct as follows:

struct Context {
    name: String,
    debug: bool
}

And after letting clap parse the CLI, we get back and instance of ArgMatches, we may create a From implementation like so:

impl From<ArgMatches> for Context {
   fn from(m: ArgMatches) -> Self {
       Context {
           name: m.value_of("name").unwrap().to_string(),
           debug: m.is_present("debug"),
       }
   }
}

fn update_from_arg_matches(&mut self, matches: &ArgMatches)[src]

@TODO@ @release @docs

Loading content...

Implementations on Foreign Types

impl<T: FromArgMatches> FromArgMatches for Box<T>[src]

Loading content...

Implementors

Loading content...