forked from extern/nushell
Get rid of header bold option (#4076)
* refactor(options): get rid of 'header_bold' option * docs(config): remove 'header_bold' from docs * fix(options): replicate logic to apply true/false in bold * style(options): apply lint fixes
This commit is contained in:
parent
75782f0f50
commit
f94a3e15f5
@ -38,7 +38,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Set coloring options",
|
description: "Set coloring options",
|
||||||
example: "config set color_config [[header_align header_bold]; [left $true]]",
|
example: "config set color_config [[header_align header_color]; [left white_bold]]",
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
|
@ -76,17 +76,14 @@ impl ConfigExtensions for NuConfig {
|
|||||||
fn header_style(&self) -> TextStyle {
|
fn header_style(&self) -> TextStyle {
|
||||||
// FIXME: I agree, this is the long way around, please suggest and alternative.
|
// FIXME: I agree, this is the long way around, please suggest and alternative.
|
||||||
let head_color = get_color_from_key_and_subkey(self, "color_config", "header_color");
|
let head_color = get_color_from_key_and_subkey(self, "color_config", "header_color");
|
||||||
let head_color_style = match head_color {
|
let (head_color_style, head_bold_bool) = match head_color {
|
||||||
Some(s) => {
|
Some(s) => (
|
||||||
lookup_ansi_color_style(s.as_string().unwrap_or_else(|_| "green".to_string()))
|
lookup_ansi_color_style(s.as_string().unwrap_or_else(|_| "green".to_string())),
|
||||||
}
|
header_bold_from_value(Some(&s)),
|
||||||
None => nu_ansi_term::Color::Green.normal(),
|
),
|
||||||
};
|
None => (nu_ansi_term::Color::Green.normal(), true),
|
||||||
let head_bold = get_color_from_key_and_subkey(self, "color_config", "header_bold");
|
|
||||||
let head_bold_bool = match head_bold {
|
|
||||||
Some(b) => header_bold_from_value(Some(&b)),
|
|
||||||
None => true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let head_align = get_color_from_key_and_subkey(self, "color_config", "header_align");
|
let head_align = get_color_from_key_and_subkey(self, "color_config", "header_align");
|
||||||
let head_alignment = match head_align {
|
let head_alignment = match head_align {
|
||||||
Some(a) => header_alignment_from_value(Some(&a)),
|
Some(a) => header_alignment_from_value(Some(&a)),
|
||||||
|
@ -102,7 +102,6 @@ pub fn string_to_lookup_value(str_prim: &str) -> String {
|
|||||||
"separator_color" => "separator_color".to_string(),
|
"separator_color" => "separator_color".to_string(),
|
||||||
"header_align" => "header_align".to_string(),
|
"header_align" => "header_align".to_string(),
|
||||||
"header_color" => "header_color".to_string(),
|
"header_color" => "header_color".to_string(),
|
||||||
"header_bold" => "header_bold".to_string(),
|
|
||||||
"header_style" => "header_style".to_string(),
|
"header_style" => "header_style".to_string(),
|
||||||
"index_color" => "index_color".to_string(),
|
"index_color" => "index_color".to_string(),
|
||||||
"leading_trailing_space_bg" => "leading_trailing_space_bg".to_string(),
|
"leading_trailing_space_bg" => "leading_trailing_space_bg".to_string(),
|
||||||
@ -144,7 +143,6 @@ pub fn get_color_config(config: &NuConfig) -> HashMap<String, Style> {
|
|||||||
hm.insert("separator_color".to_string(), Color::White.normal());
|
hm.insert("separator_color".to_string(), Color::White.normal());
|
||||||
hm.insert("header_align".to_string(), Color::Green.bold());
|
hm.insert("header_align".to_string(), Color::Green.bold());
|
||||||
hm.insert("header_color".to_string(), Color::Green.bold());
|
hm.insert("header_color".to_string(), Color::Green.bold());
|
||||||
hm.insert("header_bold".to_string(), Color::Green.bold());
|
|
||||||
hm.insert("header_style".to_string(), Style::default());
|
hm.insert("header_style".to_string(), Style::default());
|
||||||
hm.insert("index_color".to_string(), Color::Green.bold());
|
hm.insert("index_color".to_string(), Color::Green.bold());
|
||||||
hm.insert(
|
hm.insert(
|
||||||
@ -204,9 +202,6 @@ pub fn get_color_config(config: &NuConfig) -> HashMap<String, Style> {
|
|||||||
"header_color" => {
|
"header_color" => {
|
||||||
update_hashmap(key, value, &mut hm);
|
update_hashmap(key, value, &mut hm);
|
||||||
}
|
}
|
||||||
"header_bold" => {
|
|
||||||
update_hashmap(key, value, &mut hm);
|
|
||||||
}
|
|
||||||
"header_style" => {
|
"header_style" => {
|
||||||
update_hashmap(key, value, &mut hm);
|
update_hashmap(key, value, &mut hm);
|
||||||
}
|
}
|
||||||
@ -358,14 +353,7 @@ pub fn style_primitive(primitive: &str, color_hm: &HashMap<String, Style>) -> Te
|
|||||||
let style = color_hm.get("header_color");
|
let style = color_hm.get("header_color");
|
||||||
match style {
|
match style {
|
||||||
Some(s) => TextStyle::with_style(Alignment::Center, *s),
|
Some(s) => TextStyle::with_style(Alignment::Center, *s),
|
||||||
None => TextStyle::default_header(),
|
None => TextStyle::default_header().bold(Some(true)),
|
||||||
}
|
|
||||||
}
|
|
||||||
"header_bold" => {
|
|
||||||
let style = color_hm.get("header_bold");
|
|
||||||
match style {
|
|
||||||
Some(s) => TextStyle::with_style(Alignment::Center, *s),
|
|
||||||
None => TextStyle::default_header(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"header_style" => {
|
"header_style" => {
|
||||||
|
@ -1,36 +1,44 @@
|
|||||||
# config set
|
# config set
|
||||||
|
|
||||||
Sets a value in the config
|
Sets a value in the config
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> config set <key> <value> {flags}
|
> config set <key> <value> {flags}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
* `<key>` variable name to set
|
|
||||||
* `<value>` value to use
|
- `<key>` variable name to set
|
||||||
|
- `<value>` value to use
|
||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
* -h, --help: Display this help message
|
|
||||||
|
- -h, --help: Display this help message
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
Set auto pivoting
|
|
||||||
|
Set auto pivoting
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
> config set pivot_mode always
|
> config set pivot_mode always
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set line editor options
|
||||||
|
|
||||||
Set line editor options
|
|
||||||
```shell
|
```shell
|
||||||
> config set line_editor [[edit_mode, completion_type]; [emacs circular]]
|
> config set line_editor [[edit_mode, completion_type]; [emacs circular]]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set coloring options
|
||||||
|
|
||||||
Set coloring options
|
|
||||||
```shell
|
```shell
|
||||||
> config set color_config [[header_align header_bold]; [left $true]]
|
> config set color_config [[header_align header_color]; [left white_bold]]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set nested options
|
||||||
|
|
||||||
Set nested options
|
|
||||||
```shell
|
```shell
|
||||||
> config set color_config.header_color white
|
> config set color_config.header_color white
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ primitive_binary = "cyan"
|
|||||||
separator_color = "purple"
|
separator_color = "purple"
|
||||||
header_align = "l" # left|l, right|r, center|c
|
header_align = "l" # left|l, right|r, center|c
|
||||||
header_color = "c" # green|g, red|r, blue|u, black|b, yellow|y, purple|p, cyan|c, white|w
|
header_color = "c" # green|g, red|r, blue|u, black|b, yellow|y, purple|p, cyan|c, white|w
|
||||||
header_bold = true
|
|
||||||
index_color = "rd"
|
index_color = "rd"
|
||||||
leading_trailing_space_bg = "white"
|
leading_trailing_space_bg = "white"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user