Skip to content
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

Fix issue #1147 #1149

Merged
merged 1 commit into from
Aug 23, 2024
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
15 changes: 11 additions & 4 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::process;
use std::{process, str::FromStr};

use clap::{crate_description, value_parser, Arg, ArgAction, ArgMatches};
use colored::Colorize;
Expand Down Expand Up @@ -276,12 +276,19 @@ impl Cli {

// Sorting category should be restricted by clap but parse before we do
// work just in case.
let (sort, sort_reverse) = if let Some(sort) = matches.get_one::<Sort>("sort") {
(Some(*sort), false)
let (sort, sort_reverse) = if let Some(sort) = matches.get_one::<String>("sort") {
(Some(sort.clone()), false)
} else {
let sort = matches.get_one::<Sort>("rsort");
let sort = matches.get_one::<String>("rsort");
(sort.cloned(), sort.is_some())
};
let sort = sort.map(|x| match Sort::from_str(&x) {
Ok(sort) => sort,
Err(e) => {
eprintln!("Error:\n{}", e);
process::exit(1);
}
});

// Format category is overly accepting by clap (so the user knows what
// is supported) but this will fail if support is not compiled in and
Expand Down
Loading