forked from mirrors/jj
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();
|
||||
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.
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -25,11 +25,13 @@ separate(" ",
|
|||
'''
|
||||
|
||||
config_list = '''
|
||||
concat(
|
||||
if(overridden, "# "),
|
||||
name,
|
||||
"=",
|
||||
value,
|
||||
label(if(overridden, "overridden"),
|
||||
concat(
|
||||
if(overridden, "# "),
|
||||
name,
|
||||
"=",
|
||||
value,
|
||||
),
|
||||
) ++ "\n"
|
||||
'''
|
||||
|
||||
|
|
|
@ -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###"
|
||||
[38;5;8m# merge-tools.vimdiff.program="user"[39m
|
||||
[38;5;2mmerge-tools.vimdiff.program[39m=[38;5;3m"repo"[39m
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue