mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 10:25:42 +02:00
respect use_ansi_coloring configuration (#7912)
# Description Use the `use_ansi_coloring` configuration point to decide whether the output will have colors, where possible. Related: https://github.com/nushell/nushell/issues/7676  - [x] `grid -c` - [x] `perf()` # User-Facing Changes _(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)_ # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
@ -72,6 +72,7 @@ prints out the list properly."#
|
||||
None => None,
|
||||
};
|
||||
let use_grid_icons = config.use_grid_icons;
|
||||
let use_color: bool = color_param && config.use_ansi_coloring;
|
||||
|
||||
match input {
|
||||
PipelineData::Value(Value::List { vals, .. }, ..) => {
|
||||
@ -82,7 +83,7 @@ prints out the list properly."#
|
||||
items,
|
||||
call,
|
||||
width_param,
|
||||
color_param,
|
||||
use_color,
|
||||
separator_param,
|
||||
env_str,
|
||||
use_grid_icons,
|
||||
@ -99,7 +100,7 @@ prints out the list properly."#
|
||||
items,
|
||||
call,
|
||||
width_param,
|
||||
color_param,
|
||||
use_color,
|
||||
separator_param,
|
||||
env_str,
|
||||
use_grid_icons,
|
||||
@ -121,7 +122,7 @@ prints out the list properly."#
|
||||
items,
|
||||
call,
|
||||
width_param,
|
||||
color_param,
|
||||
use_color,
|
||||
separator_param,
|
||||
env_str,
|
||||
use_grid_icons,
|
||||
@ -170,7 +171,7 @@ fn create_grid_output(
|
||||
items: Vec<(usize, String, String)>,
|
||||
call: &Call,
|
||||
width_param: Option<i64>,
|
||||
color_param: bool,
|
||||
use_color: bool,
|
||||
separator_param: Option<String>,
|
||||
env_str: Option<String>,
|
||||
use_grid_icons: bool,
|
||||
@ -198,7 +199,7 @@ fn create_grid_output(
|
||||
for (_row_index, header, value) in items {
|
||||
// only output value if the header name is 'name'
|
||||
if header == "name" {
|
||||
if color_param {
|
||||
if use_color {
|
||||
if use_grid_icons {
|
||||
let no_ansi = nu_utils::strip_ansi_unlikely(&value);
|
||||
let path = std::path::Path::new(no_ansi.as_ref());
|
||||
|
Reference in New Issue
Block a user