From 598c2e3f1498a7e590ed764de7026cfed69ded71 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 23 Apr 2021 13:20:16 -0400 Subject: Deprecate --24-bit-color, replacing with --true-color (#571) Fixes #567 --- src/cli.rs | 6 +++++- src/main.rs | 2 +- src/options/set.rs | 12 ++++++++++-- src/options/theme.rs | 4 ++-- src/tests/test_example_diffs.rs | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 2ee73240..ca465454 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -494,9 +494,13 @@ pub struct Opt { /// has the value "truecolor" or "24bit". If your terminal application (the application you use /// to enter commands at a shell prompt) supports 24 bit colors, then it probably already sets /// this environment variable, in which case you don't need to do anything. - #[structopt(long = "24-bit-color", default_value = "auto")] + #[structopt(long = "true-color", default_value = "auto")] pub true_color: String, + /// Deprecated: use --true-color. + #[structopt(long = "24-bit-color")] + pub _24_bit_color: Option, + /// Whether to examine ANSI color escape sequences in raw lines received from Git and handle /// lines colored in certain ways specially. This is on by default: it is how Delta supports /// Git's --color-moved feature. Set this to "false" to disable this behavior. diff --git a/src/main.rs b/src/main.rs index aa7927cb..c687346b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -197,7 +197,7 @@ fn show_config(config: &config::Config, writer: &mut dyn Write) -> std::io::Resu // Everything else writeln!( writer, - " 24-bit-color = {true_color} + " true-color = {true_color} file-added-label = {file_added_label} file-modified-label = {file_modified_label} file-removed-label = {file_removed_label} diff --git a/src/options/set.rs b/src/options/set.rs index c04bcb89..2d112f87 100644 --- a/src/options/set.rs +++ b/src/options/set.rs @@ -40,6 +40,7 @@ macro_rules! set_options { )* if $check_names { option_names.extend(&[ + "24-bit-color", "diff-highlight", // Does not exist as a flag on config "diff-so-fancy", // Does not exist as a flag on config "features", // Processed differently @@ -551,13 +552,20 @@ fn set_widths( } fn set_true_color(opt: &mut cli::Opt) { + if opt.true_color == "auto" { + // It's equal to its default, so the user might be using the deprecated + // --24-bit-color option. + if let Some(_24_bit_color) = opt._24_bit_color.as_ref() { + opt.true_color = _24_bit_color.clone(); + } + } opt.computed.true_color = match opt.true_color.as_ref() { "always" => true, "never" => false, "auto" => is_truecolor_terminal(), _ => { eprintln!( - "Invalid value for --24-bit-color option: {} (valid values are \"always\", \"never\", and \"auto\")", + "Invalid value for --true-color option: {} (valid values are \"always\", \"never\", and \"auto\")", opt.true_color ); process::exit(1); @@ -614,7 +622,6 @@ pub mod tests { // since e.g. color-only = true (non-default) forces side-by-side = false (default). let git_config_contents = b" [delta] - 24-bit-color = never color-only = false commit-decoration-style = black black commit-style = black black @@ -656,6 +663,7 @@ pub mod tests { side-by-side = true syntax-theme = xxxyyyzzz tabs = 77 + true-color = never whitespace-error-style = black black width = 77 word-diff-regex = xxxyyyzzz diff --git a/src/options/theme.rs b/src/options/theme.rs index eb1fd50f..ef46dbea 100644 --- a/src/options/theme.rs +++ b/src/options/theme.rs @@ -188,10 +188,10 @@ mod tests { } let is_true_color = true; if is_true_color { - args.push("--24-bit-color"); + args.push("--true-color"); args.push("always"); } else { - args.push("--24-bit-color"); + args.push("--true-color"); args.push("never"); } match mode { diff --git a/src/tests/test_example_diffs.rs b/src/tests/test_example_diffs.rs index 51c713fe..de35535a 100644 --- a/src/tests/test_example_diffs.rs +++ b/src/tests/test_example_diffs.rs @@ -928,7 +928,7 @@ src/align.rs &["--color-only", "--max-line-length", "1"], &["--color-only", "--width", "1"], &["--color-only", "--tabs", "10"], - &["--color-only", "--24-bit-color", "always"], + &["--color-only", "--true-color", "always"], &["--color-only", "--inspect-raw-lines", "false"], &["--color-only", "--whitespace-error-style", "22 reverse"], ]; -- cgit v1.2.3