Skip to content

Commit

Permalink
Add CLI option to switch true colors on/off (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
spenserblack authored Jan 13, 2021
1 parent e500690 commit 503d82f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/onefetch/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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-color")
.long("true-color")
.value_name("WHEN")
.takes_value(true)
.possible_values(&["auto", "never", "always"])
.default_value("auto")
.hide_default_value(true)
.help("Specify when to use true color (*auto*, never, always).")
.long_help(
"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(
Arg::with_name("text-colors")
.short("t")
Expand Down Expand Up @@ -249,7 +263,12 @@ impl Cli {
)
.get_matches();

let true_color = cli_utils::is_truecolor_terminal();
let true_color = match matches.value_of("true-color") {
Some("always") => true,
Some("never") => 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");
Expand Down

0 comments on commit 503d82f

Please sign in to comment.