Skip to content

Commit

Permalink
PR ajeetdsouza#802: Support bulk edit
Browse files Browse the repository at this point in the history
  • Loading branch information
mataha committed Jun 15, 2024
1 parent 3556a26 commit 9e0ff11
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
6 changes: 3 additions & 3 deletions contrib/completions/_zoxide

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

6 changes: 3 additions & 3 deletions contrib/completions/zoxide.bash

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

12 changes: 9 additions & 3 deletions contrib/completions/zoxide.ts

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

6 changes: 3 additions & 3 deletions src/cmd/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ pub struct Edit {
#[derive(Clone, Debug, Subcommand)]
pub enum EditCommand {
#[clap(hide = true)]
Decrement { path: String },
Decrement { paths: Vec<String> },
#[clap(hide = true)]
Delete { path: String },
Delete { paths: Vec<String> },
#[clap(hide = true)]
Increment { path: String },
Increment { paths: Vec<String> },
#[clap(hide = true)]
Reload,
}
Expand Down
24 changes: 14 additions & 10 deletions src/cmd/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ impl Run for Edit {
match &self.cmd {
Some(cmd) => {
match cmd {
EditCommand::Decrement { path } => db.add(path, -1.0, now),
EditCommand::Delete { path } => {
EditCommand::Decrement { paths } => paths.iter().for_each(|path| {
db.add(path, -1.0, now);
}),
EditCommand::Delete { paths } => paths.iter().for_each(|path| {
db.remove(path);
}
EditCommand::Increment { path } => db.add(path, 1.0, now),
}),
EditCommand::Increment { paths } => paths.iter().for_each(|path| {
db.add(path, 1.0, now);
}),
EditCommand::Reload => {}
}
db.save()?;
Expand Down Expand Up @@ -49,18 +53,18 @@ impl Edit {
"--exact",
// Search result
"--no-sort",
// Multiple
"--multi",
// Interface
"--bind=\
btab:up,\
ctrl-r:reload(zoxide edit reload),\
ctrl-d:reload(zoxide edit delete {2..}),\
ctrl-w:reload(zoxide edit increment {2..}),\
ctrl-s:reload(zoxide edit decrement {2..}),\
ctrl-d:reload(zoxide edit delete {+2..}),\
ctrl-w:reload(zoxide edit increment {+2..}),\
ctrl-s:reload(zoxide edit decrement {+2..}),\
ctrl-z:ignore,\
double-click:ignore,\
enter:abort,\
start:reload(zoxide edit reload),\
tab:down",
start:reload(zoxide edit reload)",
"--cycle",
"--keep-right",
// Layout
Expand Down

0 comments on commit 9e0ff11

Please sign in to comment.