mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-14 16:37:42 +00:00
cli: colorize output of "config list"
This commit is contained in:
parent
7ca6744432
commit
8c0f6a53c5
4 changed files with 32 additions and 5 deletions
|
@ -226,6 +226,7 @@ pub(crate) fn cmd_config_list(
|
||||||
|
|
||||||
ui.request_pager();
|
ui.request_pager();
|
||||||
let mut formatter = ui.stdout_formatter();
|
let mut formatter = ui.stdout_formatter();
|
||||||
|
formatter.push_label("config_list")?;
|
||||||
let name_path = args
|
let name_path = args
|
||||||
.name
|
.name
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -251,6 +252,7 @@ pub(crate) fn cmd_config_list(
|
||||||
template.format(&annotated, formatter.as_mut())?;
|
template.format(&annotated, formatter.as_mut())?;
|
||||||
wrote_values = true;
|
wrote_values = true;
|
||||||
}
|
}
|
||||||
|
formatter.pop_label()?;
|
||||||
drop(formatter);
|
drop(formatter);
|
||||||
if !wrote_values {
|
if !wrote_values {
|
||||||
// Note to stderr explaining why output is empty.
|
// Note to stderr explaining why output is empty.
|
||||||
|
|
|
@ -59,6 +59,13 @@
|
||||||
"working_copy placeholder" = "bright red"
|
"working_copy placeholder" = "bright red"
|
||||||
"working_copy description placeholder" = "yellow"
|
"working_copy description placeholder" = "yellow"
|
||||||
"working_copy empty description placeholder" = "bright green"
|
"working_copy empty description placeholder" = "bright green"
|
||||||
|
|
||||||
|
"config_list name" = "green"
|
||||||
|
"config_list value" = "yellow"
|
||||||
|
"config_list overridden" = "bright black"
|
||||||
|
"config_list overridden name" = "bright black"
|
||||||
|
"config_list overridden value" = "bright black"
|
||||||
|
|
||||||
"diff header" = "yellow"
|
"diff header" = "yellow"
|
||||||
"diff empty" = "cyan"
|
"diff empty" = "cyan"
|
||||||
"diff binary" = "cyan"
|
"diff binary" = "cyan"
|
||||||
|
@ -67,6 +74,7 @@
|
||||||
"diff removed" = "red"
|
"diff removed" = "red"
|
||||||
"diff added" = "green"
|
"diff added" = "green"
|
||||||
"diff modified" = "cyan"
|
"diff modified" = "cyan"
|
||||||
|
|
||||||
"op_log id" = "blue"
|
"op_log id" = "blue"
|
||||||
"op_log user" = "yellow"
|
"op_log user" = "yellow"
|
||||||
"op_log time" = "cyan"
|
"op_log time" = "cyan"
|
||||||
|
|
|
@ -25,11 +25,13 @@ separate(" ",
|
||||||
'''
|
'''
|
||||||
|
|
||||||
config_list = '''
|
config_list = '''
|
||||||
concat(
|
label(if(overridden, "overridden"),
|
||||||
if(overridden, "# "),
|
concat(
|
||||||
name,
|
if(overridden, "# "),
|
||||||
"=",
|
name,
|
||||||
value,
|
"=",
|
||||||
|
value,
|
||||||
|
),
|
||||||
) ++ "\n"
|
) ++ "\n"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,21 @@ fn test_config_layer_override_default() {
|
||||||
# merge-tools.vimdiff.program="repo"
|
# merge-tools.vimdiff.program="repo"
|
||||||
merge-tools.vimdiff.program="command-arg"
|
merge-tools.vimdiff.program="command-arg"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
let stdout = test_env.jj_cmd_success(
|
||||||
|
&repo_path,
|
||||||
|
&[
|
||||||
|
"config",
|
||||||
|
"list",
|
||||||
|
"--color=always",
|
||||||
|
config_key,
|
||||||
|
"--include-overridden",
|
||||||
|
],
|
||||||
|
);
|
||||||
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
|
[38;5;8m# merge-tools.vimdiff.program="user"[39m
|
||||||
|
[38;5;2mmerge-tools.vimdiff.program[39m=[38;5;3m"repo"[39m
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue