Expand description
The command line of a ZeroDDS daemon, read one flag at a time.
Each bridge daemon spelled out the same loop: split --flag=VALUE, take
the value from the next argument when there is no =, name the flag a
value is missing for. They differ only in their flags, so the loop is
here and the flags stay with each daemon:
use zerodds_config::cli::{CliError, Flags};
let args = ["--domain=7".to_string(), "--topic".to_string(), "T".to_string()];
let (mut domain, mut topics) = (None::<i32>, Vec::new());
let mut flags = Flags::new(&args);
while let Some(flag) = flags.next_flag() {
match flag.name() {
"--domain" => domain = Some(flags.parsed(&flag)?),
"--topic" => topics.push(flags.value(&flag)?),
other => return Err(CliError::UnknownFlag(other.into())),
}
}
assert_eq!((domain, topics), (Some(7), vec!["T".to_string()]));Structs§
- Flag
- One flag as given: its name, and the value after
=if there was one. - Flags
- Walks a command line flag by flag.
Enums§
- CliError
- What is wrong with a daemon’s command line.