diff --git a/Cargo.lock b/Cargo.lock index de1c66c..7601be7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "jumpy" -version = "0.4.4" +version = "0.4.5" dependencies = [ "clap", "clap_complete", diff --git a/Cargo.toml b/Cargo.toml index fee0240..fcea558 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jumpy" -version = "0.4.4" +version = "0.4.5" edition = "2021" authors = ["Clément Nerma "] license = "Apache-2.0" diff --git a/src/cmd.rs b/src/cmd.rs index 12dfc36..1d11eb8 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -80,11 +80,8 @@ pub struct Query { #[derive(Args)] pub struct List { - #[clap( - long, - help = "Only display paths (sort order will be alphabetic instead of score-based)" - )] - pub just_paths: bool, + #[clap(short, long, help = "Display scores and sort directories by them")] + pub scores: bool, } #[derive(Args)] diff --git a/src/main.rs b/src/main.rs index 200401c..973717b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,14 +79,14 @@ fn main() { } } - Action::List(List { just_paths }) => { + Action::List(List { scores }) => { let mut entries = index.iter().collect::>(); - if just_paths { - entries.sort_by_key(|entry| entry.path); - } else { + if scores { entries.sort_by_key(|entry| entry.score); entries.reverse(); + } else { + entries.sort_by_key(|entry| entry.path); } let longest_score = entries @@ -97,10 +97,10 @@ fn main() { .unwrap_or(0); for IndexEntry { path, score } in entries { - if just_paths { - println!("{path}"); - } else { + if scores { println!("{score:>longest_score$} {path}"); + } else { + println!("{path}"); } } }