Skip to content

Commit 2b2aeaa

Browse files
committed
add requires param to color-resolution flag
1 parent 1c07cfb commit 2b2aeaa

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Diff for: src/onefetch/cli.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ impl Cli {
146146
Arg::with_name("color-resolution")
147147
.long("color-resolution")
148148
.value_name("VALUE")
149+
.requires("image")
149150
.takes_value(true)
150151
.max_values(1)
151152
.possible_values(&["16", "32", "64", "128", "256"])
152-
.default_value("16")
153153
.help("VALUE of color resolution to use with SIXEL backend."),
154154
)
155155
.arg(
@@ -226,11 +226,11 @@ impl Cli {
226226
None
227227
};
228228

229-
let image_colors: usize = matches
230-
.value_of("color-resolution")
231-
.unwrap()
232-
.parse()
233-
.unwrap();
229+
let image_colors = if let Some(value) = matches.value_of("color-resolution") {
230+
usize::from_str(value).unwrap()
231+
} else {
232+
16
233+
};
234234

235235
let path = String::from(matches.value_of("input").unwrap());
236236

@@ -250,11 +250,7 @@ impl Cli {
250250

251251
let disabled_fields = info_fields::get_disabled_fields(fields_to_hide)?;
252252

253-
let number_of_authors = if let Some(value) = matches.value_of("authors-number") {
254-
usize::from_str(value).unwrap()
255-
} else {
256-
3
257-
};
253+
let number_of_authors: usize = matches.value_of("authors-number").unwrap().parse().unwrap();
258254

259255
let excluded = if let Some(user_ignored) = matches.values_of("exclude") {
260256
user_ignored.map(String::from).collect()

0 commit comments

Comments
 (0)