aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdr135284 <54752759+sdr135284@users.noreply.github.com>2023-12-11 14:20:31 -0600
committerGitHub <noreply@github.com>2023-12-11 20:20:31 +0000
commit218521226fdbf26bc315d75ce02711f9885b985c (patch)
tree6a73f71e85b53f207b771464839399ab8120914d
parentfix(stats): don't require all fields under [stats] (#1437) (diff)
downloadatuin-218521226fdbf26bc315d75ce02711f9885b985c.zip
fix(history): disallow deletion if the '--limit' flag is present (#1436)
Co-authored-by: sdr13528 <sdr13528@users.noreply.github.com>
-rw-r--r--atuin/src/command/client/search.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/atuin/src/command/client/search.rs b/atuin/src/command/client/search.rs
index 2297d81b..eedf4f8b 100644
--- a/atuin/src/command/client/search.rs
+++ b/atuin/src/command/client/search.rs
@@ -104,6 +104,18 @@ pub struct Cmd {
impl Cmd {
pub async fn run(self, db: impl Database, settings: &mut Settings) -> Result<()> {
+ if (self.delete_it_all || self.delete) && self.limit.is_some() {
+ // Because of how deletion is implemented, it will always delete all matches
+ // and disregard the limit option. It is also not clear what deletion with a
+ // limit would even mean. Deleting the LIMIT most recent entries that match
+ // the search query would make sense, but that wouldn't match what's displayed
+ // when running the equivalent search, but deleting those entries that are
+ // displayed with the search would leave any duplicates of those lines which may
+ // or may not have been intended to be deleted.
+ println!("\"--limit\" is not compatible with deletion.");
+ return Ok(());
+ }
+
if self.delete && self.query.is_empty() {
println!("Please specify a query to match the items you wish to delete. If you wish to delete all history, pass --delete-it-all");
return Ok(());