option_parser: Add support for adding from a slice

Add an OptionParser::add_all method that takes a slice of option names
and use that to add to the set of parameters that the parser works on.

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-04-04 08:44:11 -07:00
parent a8ff2c50af
commit 791889cefd

View File

@@ -148,6 +148,14 @@ impl OptionParser {
self
}
pub fn add_all(&mut self, options: &[&str]) -> &mut Self {
for option in options {
self.add(option);
}
self
}
pub fn add_valueless(&mut self, option: &str) -> &mut Self {
self.options.insert(
option.to_owned(),