Skip to content

Commit a1cdcad

Browse files
authored
Merge pull request #295 from rogercyyu/feature/text-coloring
Feature/text coloring
2 parents af02010 + a23926c commit a1cdcad

File tree

4 files changed

+225
-57
lines changed

4 files changed

+225
-57
lines changed

src/onefetch/cli.rs

+26-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct Cli {
2929
pub print_languages: bool,
3030
pub true_color: bool,
3131
pub art_off: bool,
32+
pub text_colors: Vec<String>,
3233
}
3334

3435
impl Cli {
@@ -38,7 +39,9 @@ impl Cli {
3839
let possible_backends = ["kitty", "sixel"];
3940
#[cfg(windows)]
4041
let possible_backends = [];
41-
42+
let color_values = &[
43+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15",
44+
];
4245
let matches = App::new(crate_name!())
4346
.version(crate_version!())
4447
.about(crate_description!())
@@ -107,12 +110,23 @@ impl Cli {
107110
.value_name("X")
108111
.multiple(true)
109112
.takes_value(true)
110-
.possible_values(&[
111-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
112-
"15",
113-
])
113+
.possible_values(color_values)
114114
.help("Colors (X X X...) to print the ascii art."),
115115
)
116+
.arg(
117+
Arg::with_name("text-colors")
118+
.short("t")
119+
.long("text-colors")
120+
.value_name("X")
121+
.multiple(true)
122+
.takes_value(true)
123+
.max_values(6)
124+
.possible_values(color_values)
125+
.help("Allows you to customize color of info lines (X X X...)")
126+
.long_help("Allows you to customize color of info lines. \
127+
Goes in order of title, ~, underline, subtitle, colon, and info. \
128+
Example: onefetch --text-colors 9 10 11 12 13 14")
129+
)
116130
.arg(
117131
Arg::with_name("no-bold")
118132
.long("no-bold")
@@ -254,6 +268,12 @@ impl Cli {
254268
Vec::new()
255269
};
256270

271+
let text_colors = if let Some(values) = matches.values_of("text-colors") {
272+
values.map(String::from).collect()
273+
} else {
274+
Vec::new()
275+
};
276+
257277
let disabled_fields = info_fields::get_disabled_fields(fields_to_hide)?;
258278

259279
let number_of_authors: usize = matches.value_of("authors-number").unwrap().parse().unwrap();
@@ -280,6 +300,7 @@ impl Cli {
280300
excluded,
281301
print_languages,
282302
true_color,
303+
text_colors,
283304
art_off,
284305
})
285306
}

0 commit comments

Comments
 (0)