Add a config variable with engine support (#332)

* Add a config variable with engine support

* Add a config variable with engine support

* Oops, cleanup
This commit is contained in:
JT
2021-11-15 08:25:57 +13:00
committed by GitHub
parent e76451866d
commit 0f107b2830
30 changed files with 333 additions and 96 deletions

View File

@ -429,7 +429,9 @@ pub fn eval_subexpression(
// to be used later
// FIXME: the trimming of the end probably needs to live in a better place
let mut s = input.collect_string("");
let config = stack.get_config()?;
let mut s = input.collect_string("", &config);
if s.ends_with('\n') {
s.pop();
}

View File

@ -95,14 +95,32 @@ impl FromValue for f64 {
impl FromValue for String {
fn from_value(v: &Value) -> Result<Self, ShellError> {
// FIXME: we may want to fail a little nicer here
Ok(v.clone().into_string(", "))
match v {
Value::CellPath { val, .. } => Ok(val.into_string()),
Value::String { val, .. } => Ok(val.clone()),
v => Err(ShellError::CantConvert(
"string".into(),
v.get_type().to_string(),
v.span()?,
)),
}
}
}
impl FromValue for Spanned<String> {
fn from_value(v: &Value) -> Result<Self, ShellError> {
Ok(Spanned {
item: v.clone().into_string(", "),
item: match v {
Value::CellPath { val, .. } => val.into_string(),
Value::String { val, .. } => val.clone(),
v => {
return Err(ShellError::CantConvert(
"string".into(),
v.get_type().to_string(),
v.span()?,
))
}
},
span: v.span()?,
})
}