Skip to content

Commit 503d82f

Browse files
authored
Add CLI option to switch true colors on/off (#373)
1 parent e500690 commit 503d82f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Diff for: src/onefetch/cli.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,20 @@ impl Cli {
174174
.possible_values(color_values)
175175
.help("Colors (X X X...) to print the ascii art."),
176176
)
177+
.arg(
178+
Arg::with_name("true-color")
179+
.long("true-color")
180+
.value_name("WHEN")
181+
.takes_value(true)
182+
.possible_values(&["auto", "never", "always"])
183+
.default_value("auto")
184+
.hide_default_value(true)
185+
.help("Specify when to use true color (*auto*, never, always).")
186+
.long_help(
187+
"Specify when to use true color (*auto*, never, always). \n\
188+
If set to auto: true color will be enabled if supported by the terminal."
189+
)
190+
)
177191
.arg(
178192
Arg::with_name("text-colors")
179193
.short("t")
@@ -249,7 +263,12 @@ impl Cli {
249263
)
250264
.get_matches();
251265

252-
let true_color = cli_utils::is_truecolor_terminal();
266+
let true_color = match matches.value_of("true-color") {
267+
Some("always") => true,
268+
Some("never") => false,
269+
Some("auto") => cli_utils::is_truecolor_terminal(),
270+
_ => unreachable!(),
271+
};
253272
let no_bold = matches.is_present("no-bold");
254273
let no_merges = matches.is_present("no-merge-commits");
255274
let no_color_palette = matches.is_present("no-color-palette");

0 commit comments

Comments
 (0)