Adds deleting logins

Signed-off-by: Ash Svitan <selfsigned-ash@proton.me>
This commit is contained in:
2026-04-30 21:48:05 +02:00
parent 3719b63d73
commit 8313188825
3 changed files with 32 additions and 1 deletions
+18
View File
@@ -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(());
}
+12 -1
View File
@@ -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<LoginItem> {
.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);
}
+2
View File
@@ -1,9 +1,11 @@
use std::io;
use std::process::Command;
pub fn sh(command: impl Into<String>) -> String {
let output = Command::new("sh")
.arg("-c")
.arg(command.into())
.stderr(io::stderr())
.output()
.expect("Failed to execute command");