✨ Adds deleting logins
Signed-off-by: Ash Svitan <selfsigned-ash@proton.me>
This commit is contained in:
+18
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user