Allow keeping selected environment variables from removed overlay (#6007)

* Allow keeping selected env from removed overlay

* Remove some duplicate code

* Change --keep-all back to --keep-custom

Because, apparently, you cannot have a named flag called --keep-all,
otherwise tests fail?

* Fix missing line and wrong test value
This commit is contained in:
Jakub Žádník
2022-07-11 23:58:28 +03:00
committed by GitHub
parent 9b6b817276
commit f3036b8cfd
3 changed files with 84 additions and 14 deletions

View File

@ -238,6 +238,35 @@ impl FromValue for Vec<String> {
}
}
impl FromValue for Vec<Spanned<String>> {
fn from_value(v: &Value) -> Result<Self, ShellError> {
// FIXME: we may want to fail a little nicer here
match v {
Value::List { vals, .. } => vals
.iter()
.map(|val| match val {
Value::String { val, span } => Ok(Spanned {
item: val.clone(),
span: *span,
}),
c => Err(ShellError::CantConvert(
"string".into(),
c.get_type().to_string(),
c.span()?,
None,
)),
})
.collect::<Result<Vec<Spanned<String>>, ShellError>>(),
v => Err(ShellError::CantConvert(
"string".into(),
v.get_type().to_string(),
v.span()?,
None,
)),
}
}
}
impl FromValue for Vec<bool> {
fn from_value(v: &Value) -> Result<Self, ShellError> {
match v {