mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
option_parser: For tuple list type strip brackets only once
The new option parsing for "[..,]" syntax is much stricter and requires that everything is balanced in terms of brackets. Change the stripping of the brackets to only strip the first and last one rather than multiple: e.g. "[[a,b], [c,d]]" becomes "[a,b],[c,d]" rather than "a,b], [c" Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
19957d4fa4
commit
9f89e0a4e0
@ -305,8 +305,13 @@ impl<S: FromStr, T: TupleValue> FromStr for Tuple<S, T> {
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
let mut list: Vec<(S, T)> = Vec::new();
|
||||
|
||||
let tuples_list = split_commas(s.trim().trim_matches(|c| c == '[' || c == ']'))
|
||||
.map_err(TupleError::SplitOutsideBrackets)?;
|
||||
let body = s
|
||||
.trim()
|
||||
.strip_prefix('[')
|
||||
.and_then(|s| s.strip_suffix(']'))
|
||||
.ok_or_else(|| TupleError::InvalidValue(s.to_string()))?;
|
||||
|
||||
let tuples_list = split_commas(body).map_err(TupleError::SplitOutsideBrackets)?;
|
||||
for tuple in tuples_list.iter() {
|
||||
let items: Vec<&str> = tuple.split('@').collect();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user