Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dissallow deletion if the '--limit' flag is present #1436

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions atuin/src/command/client/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
Expand Down