From 83131888255b463ec4d9f9be310c6a8dceef0297 Mon Sep 17 00:00:00 2001 From: Ash Svitan Date: Thu, 30 Apr 2026 21:48:05 +0200 Subject: [PATCH] :sparkles: Adds deleting logins Signed-off-by: Ash Svitan --- src/main.rs | 18 ++++++++++++++++++ src/pass.rs | 13 ++++++++++++- src/sh.rs | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 62fc539..fd88fdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -142,5 +142,23 @@ fn main() -> Result<(), Error> { } } + for pass_login in pass_logins { + let consent = ask_consent( + format!("Attempting to delete {}:", pass_login.title), + format!( + "{}", + if pass_login.username.is_empty() { + pass_login.email + } else { + pass_login.username + } + ), + format!("{}", pass_login.password), + )?; + if consent { + pass::trash(&vault, pass_login.id); + } + } + return Ok(()); } diff --git a/src/pass.rs b/src/pass.rs index 0058477..1ce7b8e 100644 --- a/src/pass.rs +++ b/src/pass.rs @@ -25,6 +25,7 @@ pub struct Items { pub struct Item { pub id: String, pub content: ItemContent, + pub state: String, } #[derive(Deserialize, Debug, Clone)] @@ -107,7 +108,9 @@ pub fn get_logins(items: Items) -> Vec { .items .iter() .filter(|item| { - if let None = item.content.content.login { + if item.state.to_lowercase() != "active" { + false + } else if let None = item.content.content.login { false } else { true @@ -154,3 +157,11 @@ pub fn create(vault: &String, title: String, user: String, password: String) { )); println!("> {}", output); } + +pub fn trash(vault: &String, id: String) { + let output = sh::sh(format!( + "{} item trash --vault-name '{}' --item-id '{}'", + EXECUTABLE, vault, id + )); + println!("> {}", output); +} diff --git a/src/sh.rs b/src/sh.rs index 4f99563..42db266 100644 --- a/src/sh.rs +++ b/src/sh.rs @@ -1,9 +1,11 @@ +use std::io; use std::process::Command; pub fn sh(command: impl Into) -> String { let output = Command::new("sh") .arg("-c") .arg(command.into()) + .stderr(io::stderr()) .output() .expect("Failed to execute command");