Trait FromArgMatches
trait FromArgMatches: Sized
Converts an instance of ArgMatches to a user-defined container.
Derived as part of Parser, Args, and Subcommand.
Required Methods
fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>Instantiate
SelffromArgMatches, parsing the arguments as needed.Motivation: If our application had two CLI options,
--name <STRING>and the flag--debug, we may create a struct as follows:#We then need to convert the
ArgMatchesthatclapgenerated into our struct.from_arg_matchesserves as the equivalent of:#fn update_from_arg_matches(self: &mut Self, matches: &ArgMatches) -> Result<(), Error>Assign values from
ArgMatchestoself.
Provided Methods
fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error>Instantiate
SelffromArgMatches, parsing the arguments as needed.Motivation: If our application had two CLI options,
--name <STRING>and the flag--debug, we may create a struct as follows:#We then need to convert the
ArgMatchesthatclapgenerated into our struct.from_arg_matches_mutserves as the equivalent of:#fn update_from_arg_matches_mut(self: &mut Self, matches: &mut ArgMatches) -> Result<(), Error>Assign values from
ArgMatchestoself.
Implementors
impl<T: FromArgMatches> FromArgMatches for Box<T>