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

@ -49,10 +49,13 @@ impl Command for BuildString {
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
let config = stack.get_config()?;
let output = call
.positional
.iter()
.map(|expr| eval_expression(engine_state, stack, expr).map(|val| val.into_string(", ")))
.map(|expr| {
eval_expression(engine_state, stack, expr).map(|val| val.into_string(", ", &config))
})
.collect::<Result<Vec<String>, ShellError>>()?;
Ok(Value::String {

View File

@ -34,12 +34,14 @@ impl Command for StrCollect {
) -> Result<PipelineData, ShellError> {
let separator: Option<String> = call.opt(engine_state, stack, 0)?;
let config = stack.get_config()?;
// Hmm, not sure what we actually want. If you don't use debug_string, Date comes out as human readable
// which feels funny
#[allow(clippy::needless_collect)]
let strings: Vec<String> = input
.into_iter()
.map(|value| value.debug_string("\n"))
.map(|value| value.debug_string("\n", &config))
.collect();
let output = if let Some(separator) = separator {