macro_rules! macro_get_args {
($matches:ident, $name:expr) => { ... };
}
Expand description
§macro_get_args
Macro
Retrieve a named argument from a clap::ArgMatches
object.
§Arguments
$matches
- Aclap::ArgMatches
object representing the parsed command-line arguments.$name
- A string literal specifying the name of the argument to retrieve.
§Behaviour
The macro_get_args
macro retrieves the value of the named argument $name
from the $matches
object. If the argument is found and its value can be converted to String
, the macro returns the value as a Result<String, String>
. If the argument is not found or its value cannot be converted to String
, an Err
variant is returned with an error message indicating the omission of the required parameter.
The error message includes the name of the omitted parameter ($name
) to assist with troubleshooting and providing meaningful feedback to users.
§Notes
- This macro assumes the availability of the
clap
crate and the presence of a validArgMatches
object. - Make sure to adjust the code example by providing a valid
ArgMatches
object and replacing"arg_name"
with the actual name of the argument you want to retrieve.