From 195e788f921c5840d62afe7c745fcb94b5b9b141 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 24 Mar 2024 16:03:00 +0900 Subject: [PATCH] cli: colorize only "Error: "/"Warning: "/"Hint: " headings I think long message is easier to read if printed in the default color. Errors and warnings are printed in bold to make them distinct. --- cli/src/config/colors.toml | 12 ++++++------ cli/tests/test_global_opts.rs | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/src/config/colors.toml b/cli/src/config/colors.toml index bc5372c52e..e2fa251ef2 100644 --- a/cli/src/config/colors.toml +++ b/cli/src/config/colors.toml @@ -1,10 +1,10 @@ [colors] -"error" = "red" -"warning" = "yellow" -"hint" = "cyan" -"error heading" = { bold = true } -"warning heading" = { bold = true } -"hint heading" = { bold = true } +"error" = { fg = "default", bold = true } +"warning" = { fg = "default", bold = true } +"hint" = { fg = "default" } +"error heading" = { fg = "red", bold = true } +"warning heading" = { fg = "yellow", bold = true } +"hint heading" = { fg = "cyan", bold = true } "conflict_description" = "yellow" "conflict_description difficult" = "red" diff --git a/cli/tests/test_global_opts.rs b/cli/tests/test_global_opts.rs index 12285bd35d..fa8ce5860d 100644 --- a/cli/tests/test_global_opts.rs +++ b/cli/tests/test_global_opts.rs @@ -395,15 +395,15 @@ fn test_color_ui_messages() { // hint and error let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["-R."]); insta::assert_snapshot!(stderr, @r###" - Hint: Use `jj -h` for a list of available commands. - Run `jj config set --user ui.default-command log` to disable this message. - Error: There is no jj repo in "." + Hint: Use `jj -h` for a list of available commands. + Run `jj config set --user ui.default-command log` to disable this message. + Error: There is no jj repo in "." "###); // warning let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["log", "@"]); insta::assert_snapshot!(stderr, @r###" - Warning: The argument "@" is being interpreted as a path. To specify a revset, pass -r "@" instead. + Warning: The argument "@" is being interpreted as a path. To specify a revset, pass -r "@" instead. "###); // error inlined in template output @@ -419,7 +419,7 @@ fn test_color_ui_messages() { ); insta::assert_snapshot!(stdout, @r###" 8bb159bc30a9859930e567eb9238a7c43ee6744d - <Error: No commit available> (elided revisions) + <Error: No commit available> (elided revisions) 0000000000000000000000000000000000000000 "###); }