mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 08:38:34 +02:00
Move config to be an env var (#5230)
* Move config to be an env var * fix fmt and tests
This commit is contained in:
@ -64,7 +64,7 @@ prints out the list properly."#
|
||||
let width_param: Option<i64> = call.get_flag(engine_state, stack, "width")?;
|
||||
let color_param: bool = call.has_flag("color");
|
||||
let separator_param: Option<String> = call.get_flag(engine_state, stack, "separator")?;
|
||||
let config = stack.get_config().unwrap_or_default();
|
||||
let config = engine_state.get_config();
|
||||
let env_str = match stack.get_env_var(engine_state, "LS_COLORS") {
|
||||
Some(v) => Some(env_to_string("LS_COLORS", &v, engine_state, stack)?),
|
||||
None => None,
|
||||
@ -74,7 +74,7 @@ prints out the list properly."#
|
||||
match input {
|
||||
PipelineData::Value(Value::List { vals, .. }, ..) => {
|
||||
// dbg!("value::list");
|
||||
let data = convert_to_list(vals, &config, call.head);
|
||||
let data = convert_to_list(vals, config, call.head);
|
||||
if let Some(items) = data {
|
||||
Ok(create_grid_output(
|
||||
items,
|
||||
@ -91,7 +91,7 @@ prints out the list properly."#
|
||||
}
|
||||
PipelineData::ListStream(stream, ..) => {
|
||||
// dbg!("value::stream");
|
||||
let data = convert_to_list(stream, &config, call.head);
|
||||
let data = convert_to_list(stream, config, call.head);
|
||||
if let Some(items) = data {
|
||||
Ok(create_grid_output(
|
||||
items,
|
||||
@ -112,7 +112,7 @@ prints out the list properly."#
|
||||
let mut items = vec![];
|
||||
|
||||
for (i, (c, v)) in cols.into_iter().zip(vals.into_iter()).enumerate() {
|
||||
items.push((i, c, v.into_string(", ", &config)))
|
||||
items.push((i, c, v.into_string(", ", config)))
|
||||
}
|
||||
|
||||
Ok(create_grid_output(
|
||||
|
@ -56,8 +56,8 @@ impl Command for Table {
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
let head = call.head;
|
||||
let ctrlc = engine_state.ctrlc.clone();
|
||||
let config = stack.get_config().unwrap_or_default();
|
||||
let color_hm = get_color_config(&config);
|
||||
let config = engine_state.get_config();
|
||||
let color_hm = get_color_config(config);
|
||||
let start_num: Option<i64> = call.get_flag(engine_state, stack, "start-number")?;
|
||||
let row_offset = start_num.unwrap_or_default() as usize;
|
||||
|
||||
@ -99,7 +99,6 @@ impl Command for Table {
|
||||
ListStream::from_stream(vals.into_iter(), ctrlc.clone()),
|
||||
call,
|
||||
row_offset,
|
||||
config,
|
||||
ctrlc,
|
||||
metadata,
|
||||
),
|
||||
@ -109,7 +108,6 @@ impl Command for Table {
|
||||
stream,
|
||||
call,
|
||||
row_offset,
|
||||
config,
|
||||
ctrlc,
|
||||
metadata,
|
||||
),
|
||||
@ -123,7 +121,7 @@ impl Command for Table {
|
||||
style: TextStyle::default_field(),
|
||||
},
|
||||
StyledString {
|
||||
contents: v.into_abbreviated_string(&config),
|
||||
contents: v.into_abbreviated_string(config),
|
||||
style: TextStyle::default(),
|
||||
},
|
||||
])
|
||||
@ -132,10 +130,10 @@ impl Command for Table {
|
||||
let table = nu_table::Table {
|
||||
headers: vec![],
|
||||
data: output,
|
||||
theme: load_theme_from_config(&config),
|
||||
theme: load_theme_from_config(config),
|
||||
};
|
||||
|
||||
let result = nu_table::draw_table(&table, term_width, &color_hm, &config);
|
||||
let result = nu_table::draw_table(&table, term_width, &color_hm, config);
|
||||
|
||||
Ok(Value::String {
|
||||
val: result,
|
||||
@ -149,7 +147,7 @@ impl Command for Table {
|
||||
self.run(engine_state, stack, call, base_pipeline)
|
||||
}
|
||||
PipelineData::Value(x @ Value::Range { .. }, ..) => Ok(Value::String {
|
||||
val: x.into_string("", &config),
|
||||
val: x.into_string("", config),
|
||||
span: call.head,
|
||||
}
|
||||
.into_pipeline_data()),
|
||||
@ -195,7 +193,6 @@ fn handle_row_stream(
|
||||
stream: ListStream,
|
||||
call: &Call,
|
||||
row_offset: usize,
|
||||
config: Config,
|
||||
ctrlc: Option<Arc<AtomicBool>>,
|
||||
metadata: Option<PipelineMetadata>,
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
@ -203,7 +200,7 @@ fn handle_row_stream(
|
||||
Some(PipelineMetadata {
|
||||
data_source: DataSource::Ls,
|
||||
}) => {
|
||||
let config = config.clone();
|
||||
let config = engine_state.config.clone();
|
||||
let ctrlc = ctrlc.clone();
|
||||
|
||||
let ls_colors = match stack.get_env_var(engine_state, "LS_COLORS") {
|
||||
@ -281,7 +278,7 @@ fn handle_row_stream(
|
||||
stdout: Some(RawStream::new(
|
||||
Box::new(PagingTableCreator {
|
||||
row_offset,
|
||||
config,
|
||||
config: engine_state.get_config().clone(),
|
||||
ctrlc: ctrlc.clone(),
|
||||
head,
|
||||
stream,
|
||||
|
Reference in New Issue
Block a user