Skip to content

Commit

Permalink
Replace '--just-paths' option with '--score' (inverse behaviour)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed Dec 29, 2024
1 parent da9b59d commit a600356
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jumpy"
version = "0.4.4"
version = "0.4.5"
edition = "2021"
authors = ["Clément Nerma <clement.nerma@gmail.com>"]
license = "Apache-2.0"
Expand Down
7 changes: 2 additions & 5 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ fn main() {
}
}

Action::List(List { just_paths }) => {
Action::List(List { scores }) => {
let mut entries = index.iter().collect::<Vec<_>>();

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
Expand All @@ -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}");
}
}
}
Expand Down

0 comments on commit a600356

Please sign in to comment.