ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: colorize output of "config list"

This commit is contained in:
Yuya Nishihara 2024-03-04 18:35:14 +09:00
parent 7ca6744432
commit 8c0f6a53c5
4 changed files with 32 additions and 5 deletions

View file

@ -226,6 +226,7 @@ pub(crate) fn cmd_config_list(
ui.request_pager();
let mut formatter = ui.stdout_formatter();
formatter.push_label("config_list")?;
let name_path = args
.name
.as_ref()
@ -251,6 +252,7 @@ pub(crate) fn cmd_config_list(
template.format(&annotated, formatter.as_mut())?;
wrote_values = true;
}
formatter.pop_label()?;
drop(formatter);
if !wrote_values {
// Note to stderr explaining why output is empty.

View file

@ -59,6 +59,13 @@
"working_copy placeholder" = "bright red"
"working_copy description placeholder" = "yellow"
"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 empty" = "cyan"
"diff binary" = "cyan"
@ -67,6 +74,7 @@
"diff removed" = "red"
"diff added" = "green"
"diff modified" = "cyan"
"op_log id" = "blue"
"op_log user" = "yellow"
"op_log time" = "cyan"

View file

@ -25,11 +25,13 @@ separate(" ",
'''
config_list = '''
concat(
if(overridden, "# "),
name,
"=",
value,
label(if(overridden, "overridden"),
concat(
if(overridden, "# "),
name,
"=",
value,
),
) ++ "\n"
'''

View file

@ -254,6 +254,21 @@ fn test_config_layer_override_default() {
# merge-tools.vimdiff.program="repo"
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###"
# merge-tools.vimdiff.program="user"
merge-tools.vimdiff.program="repo"
"###);
}
#[test]