From 12f28fc68b0877d5296de8731cd2b4d46fe8ee43 Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Tue, 12 Jan 2021 13:58:43 -0500 Subject: [PATCH 1/2] Add CLI option to switch true colors on/off Allows user to control if onefetch should attempt to write true colors to the terminal. --- src/onefetch/cli.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/onefetch/cli.rs b/src/onefetch/cli.rs index 385ca605f..9efe1d67e 100644 --- a/src/onefetch/cli.rs +++ b/src/onefetch/cli.rs @@ -174,6 +174,20 @@ impl Cli { .possible_values(color_values) .help("Colors (X X X...) to print the ascii art."), ) + .arg( + Arg::with_name("true-colors") + .value_name("SETTING") + .long("true-color") + .possible_values(&["auto", "on", "off"]) + .default_value("auto") + .help("control the display of true colors (auto, on, off)") + .long_help( + "- auto: detect if true colors are supported +- on: force true colors to be displayed +- off: force only 8 standard colors to be displayed +" + ) + ) .arg( Arg::with_name("text-colors") .short("t") @@ -249,7 +263,12 @@ impl Cli { ) .get_matches(); - let true_color = cli_utils::is_truecolor_terminal(); + let true_color = match matches.value_of("true-colors") { + Some("on") => true, + Some("off") => false, + Some("auto") => cli_utils::is_truecolor_terminal(), + _ => unreachable!(), + }; let no_bold = matches.is_present("no-bold"); let no_merges = matches.is_present("no-merge-commits"); let no_color_palette = matches.is_present("no-color-palette"); From 47bb562bbac16e4fc51d180ca577cb1c1141e2aa Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Tue, 12 Jan 2021 16:11:59 -0500 Subject: [PATCH 2/2] Make true-color flag consistent with other flags Co-authored-by: Ossama Hjaji --- src/onefetch/cli.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/onefetch/cli.rs b/src/onefetch/cli.rs index 9efe1d67e..0e40b1f2f 100644 --- a/src/onefetch/cli.rs +++ b/src/onefetch/cli.rs @@ -175,17 +175,17 @@ impl Cli { .help("Colors (X X X...) to print the ascii art."), ) .arg( - Arg::with_name("true-colors") - .value_name("SETTING") + Arg::with_name("true-color") .long("true-color") - .possible_values(&["auto", "on", "off"]) + .value_name("WHEN") + .takes_value(true) + .possible_values(&["auto", "never", "always"]) .default_value("auto") - .help("control the display of true colors (auto, on, off)") + .hide_default_value(true) + .help("Specify when to use true color (*auto*, never, always).") .long_help( - "- auto: detect if true colors are supported -- on: force true colors to be displayed -- off: force only 8 standard colors to be displayed -" + "Specify when to use true color (*auto*, never, always). \n\ + If set to auto: true color will be enabled if supported by the terminal." ) ) .arg( @@ -263,9 +263,9 @@ impl Cli { ) .get_matches(); - let true_color = match matches.value_of("true-colors") { - Some("on") => true, - Some("off") => false, + let true_color = match matches.value_of("true-color") { + Some("always") => true, + Some("never") => false, Some("auto") => cli_utils::is_truecolor_terminal(), _ => unreachable!(), };