summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2023-04-15 10:24:59 +0100
committerGitHub <noreply@github.com>2023-04-15 10:24:59 +0100
commitd5515f5bcd5b22393ee7dc055b4e4e8a9d7cb169 (patch)
treeaaa25bc23c6170b5a1f9218568b118be225d83e8
parent64671a17c1e353b37ed432c9d7a5a1403be5d3b4 (diff)
Avoid accidentally deleting all history, but allow it if intended (#878)
* Avoid accidentally deleting all history, but allow it if intended * docs
-rw-r--r--atuin/src/command/client/search.rs18
-rw-r--r--docs/docs/commands/search.md1
2 files changed, 18 insertions, 1 deletions
diff --git a/atuin/src/command/client/search.rs b/atuin/src/command/client/search.rs
index 356ae251..7dbb9c43 100644
--- a/atuin/src/command/client/search.rs
+++ b/atuin/src/command/client/search.rs
@@ -83,6 +83,10 @@ pub struct Cmd {
#[arg(long)]
delete: bool,
+ /// Delete EVERYTHING!
+ #[arg(long)]
+ delete_it_all: bool,
+
/// Reverse the order of results, oldest first
#[arg(long, short)]
reverse: bool,
@@ -96,6 +100,18 @@ pub struct Cmd {
impl Cmd {
pub async fn run(self, mut db: impl Database, settings: &mut Settings) -> Result<()> {
+ 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(());
+ }
+
+ if self.delete_it_all && !self.query.is_empty() {
+ println!(
+ "--delete-it-all will delete ALL of your history! It does not require a query."
+ );
+ return Ok(());
+ }
+
if self.search_mode.is_some() {
settings.search_mode = self.search_mode.unwrap();
}
@@ -131,7 +147,7 @@ impl Cmd {
}
// if we aren't deleting, print it all
- if self.delete {
+ if self.delete || self.delete_it_all {
// delete it
// it only took me _years_ to add this
// sorry
diff --git a/docs/docs/commands/search.md b/docs/docs/commands/search.md
index 8714292c..f3217f07 100644
--- a/docs/docs/commands/search.md
+++ b/docs/docs/commands/search.md
@@ -22,6 +22,7 @@ appended with a wildcard).
| `--limit` | Limit the number of results (default: none) |
| `--offset` | Offset from the start of the results (default: none) |
| `--delete` | Delete history matching this query |
+| `--delete-it-all` | Delete all shell history |
| `--reverse` | Reverse order of search results, oldest first |
## `atuin search -i`