Skip to content

Commit 6776a78

Browse files
committed
feat(cli): add a 'none' option to --show
1 parent 89eccc2 commit 6776a78

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/cli.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,25 @@ fn show_option_versions(command: &str) -> Arg {
224224
r#"{short_help}
225225
226226
<bold><underline>Values:</underline></bold>
227-
<blue>ignored</> Show instances and dependencies which syncpack is ignoring
228227
<blue>instances</> Show every instance of every dependency
229228
<blue>hints</> Show a hint alongside dependencies developed in this repo
230229
<blue>statuses</> Show specifically how/why a dependency or instance is valid or invalid
231230
<blue>all</> Shorthand to enable all of the above
231+
<blue>none</> Shorthand to disable all of the above
232232
233233
<bold><underline>Examples:</underline></bold>
234234
<dim>Only opt into showing status codes</dim>
235235
<dim>$</dim> <blue><bold>syncpack {command}</bold> --show statuses</>
236-
<dim>Show all instances, including ignored</dim>
237-
<dim>$</dim> <blue><bold>syncpack {command}</bold> --show ignored,instances</>
236+
<dim>Show all instances, not just their names</dim>
237+
<dim>$</dim> <blue><bold>syncpack {command}</bold> --show instances</>
238238
<dim>Show highest level of detail</dim>
239-
<dim>$</dim> <blue><bold>syncpack {command}</bold> --show all</>"#
239+
<dim>$</dim> <blue><bold>syncpack {command}</bold> --show all</>
240+
<dim>Show lowest level of detail</dim>
241+
<dim>$</dim> <blue><bold>syncpack {command}</bold> --show none</>"#
240242
))
241243
.value_delimiter(',')
242-
.value_parser(["hints", "ignored", "instances", "statuses", "all"])
243-
.default_value("hints,instances,statuses")
244+
.value_parser(["hints", "instances", "statuses", "all", "none"])
245+
.default_value("all")
244246
}
245247

246248
fn sort_option(command: &str) -> Arg {
@@ -490,10 +492,14 @@ fn should_show(matches: &ArgMatches, name: &str) -> bool {
490492
.ok()
491493
.flatten()
492494
.map(|show| {
493-
show
494-
.collect_vec()
495-
.iter()
496-
.any(|value| value == &&"all".to_string() || value == &&name.to_string())
495+
let names = show.collect_vec();
496+
if names.contains(&&"all".to_string()) {
497+
true
498+
} else if names.contains(&&"none".to_string()) {
499+
false
500+
} else {
501+
names.contains(&&name.to_string())
502+
}
497503
})
498504
.unwrap_or(false)
499505
}

0 commit comments

Comments
 (0)