Function design_pattern_examples_rust::parse_options
source · pub(crate) fn parse_options(
args: &[String],
exercise_list: &Vec<Exercise>
) -> Result<Options, &'static str>
Expand description
Helper function to parse the given options and return the results in the given Options structure. Displays help if requested.
Parameters
-
args
A list of strings containing the command line arguments (should not include the program name, which is normally the first item)
-
exercises
List of Exercise objects to display if help is needed.
Returns
Ok<Options>
if successful (the Options structure is filled in with
command line parameters. Returns Err<"">
if help was requested and
displayed (and therefore exit from program is desired).