Skip to content

Add CLI option to switch true colors on/off #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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