mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:05:27 +02:00
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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user