Skip to main content

parse_args

Function parse_args 

Source
pub fn parse_args<I, S>(args: I) -> Result<CliCommand, CliError>
where I: IntoIterator<Item = S>, S: Into<OsString>,
Expand description

Parses the minimal bootloader flags.

The first argument is treated as the program name and skipped, matching std::env::args_os. An empty argument list selects CliCommand::Help.

ยงExamples

use sim_run_core::{parse_args, CliCommand};

assert_eq!(parse_args(["sim", "--version"]).unwrap(), CliCommand::Version);

let CliCommand::Boot(boot) = parse_args(["sim", "--codec", "json"]).unwrap() else {
    panic!("expected a boot command");
};
assert_eq!(boot.codec.as_deref(), Some("json"));