mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-22 04:25:21 +00:00
vmm: config: Accept empty value strings
The integration tests and documentation make use of empty value strings like "--net tap=" accept them but return None so that the default value will be used as expected. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
218c780f67
commit
057e71d266
@ -132,7 +132,10 @@ impl OptionParser {
|
||||
}
|
||||
|
||||
pub fn get(&self, option: &str) -> Option<String> {
|
||||
self.options.get(option).and_then(|v| v.value.clone())
|
||||
self.options
|
||||
.get(option)
|
||||
.and_then(|v| v.value.clone())
|
||||
.and_then(|s| if s.is_empty() { None } else { Some(s) })
|
||||
}
|
||||
|
||||
pub fn is_set(&self, option: &str) -> bool {
|
||||
@ -143,7 +146,7 @@ impl OptionParser {
|
||||
}
|
||||
|
||||
pub fn convert<T: FromStr>(&self, option: &str) -> OptionParserResult<Option<T>> {
|
||||
match self.options.get(option).and_then(|v| v.value.as_ref()) {
|
||||
match self.get(option) {
|
||||
None => Ok(None),
|
||||
Some(v) => Ok(Some(v.parse().map_err(|_| {
|
||||
OptionParserError::Conversion(option.to_owned(), v.to_owned())
|
||||
|
Loading…
x
Reference in New Issue
Block a user