Move config to be an env var (#5230)

* Move config to be an env var

* fix fmt and tests
This commit is contained in:
JT
2022-04-19 10:28:01 +12:00
committed by GitHub
parent 409f1480f5
commit 76079d5183
52 changed files with 455 additions and 608 deletions

View File

@ -52,11 +52,11 @@ impl Command for BuildString {
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
let config = stack.get_config().unwrap_or_default();
let config = engine_state.get_config();
let output = call
.positional_iter()
.map(|expr| {
eval_expression(engine_state, stack, expr).map(|val| val.into_string(", ", &config))
eval_expression(engine_state, stack, expr).map(|val| val.into_string(", ", config))
})
.collect::<Result<Vec<String>, ShellError>>()?;

View File

@ -87,8 +87,8 @@ fn detect_columns(
let num_rows_to_skip: Option<usize> = call.get_flag(engine_state, stack, "skip")?;
let noheader = call.has_flag("no-headers");
let ctrlc = engine_state.ctrlc.clone();
let config = stack.get_config()?;
let input = input.collect_string("", &config)?;
let config = engine_state.get_config();
let input = input.collect_string("", config)?;
#[allow(clippy::needless_collect)]
let input: Vec<_> = input

View File

@ -35,14 +35,14 @@ impl Command for Format {
call: &Call,
input: PipelineData,
) -> Result<PipelineData, ShellError> {
let config = stack.get_config()?;
let config = engine_state.get_config();
let specified_pattern: Result<Value, ShellError> = call.req(engine_state, stack, 0);
match specified_pattern {
Err(e) => Err(e),
Ok(pattern) => {
let string_pattern = pattern.as_string()?;
let ops = extract_formatting_operations(string_pattern);
format(input, &ops, call.head, &config)
format(input, &ops, call.head, config)
}
}
}

View File

@ -41,7 +41,7 @@ impl Command for StrCollect {
) -> Result<PipelineData, ShellError> {
let separator: Option<String> = call.opt(engine_state, stack, 0)?;
let config = stack.get_config().unwrap_or_default();
let config = engine_state.get_config();
// let output = input.collect_string(&separator.unwrap_or_default(), &config)?;
// Hmm, not sure what we actually want. If you don't use debug_string, Date comes out as human readable
@ -54,7 +54,7 @@ impl Command for StrCollect {
return Err(error);
}
value => {
strings.push(value.debug_string("\n", &config));
strings.push(value.debug_string("\n", config));
}
}
}