Skip to content

Commit

Permalink
fix issue #1147 (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
qtfkwk authored Aug 23, 2024
1 parent 3e09c23 commit bf009ef
Showing 1 changed file with 11 additions and 4 deletions.
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

0 comments on commit bf009ef

Please sign in to comment.