✨ 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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-1
@@ -25,6 +25,7 @@ pub struct Items {
|
|||||||
pub struct Item {
|
pub struct Item {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub content: ItemContent,
|
pub content: ItemContent,
|
||||||
|
pub state: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
@@ -107,7 +108,9 @@ pub fn get_logins(items: Items) -> Vec<LoginItem> {
|
|||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|item| {
|
.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
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
@@ -154,3 +157,11 @@ pub fn create(vault: &String, title: String, user: String, password: String) {
|
|||||||
));
|
));
|
||||||
println!("> {}", output);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
use std::io;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn sh(command: impl Into<String>) -> String {
|
pub fn sh(command: impl Into<String>) -> String {
|
||||||
let output = Command::new("sh")
|
let output = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(command.into())
|
.arg(command.into())
|
||||||
|
.stderr(io::stderr())
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to execute command");
|
.expect("Failed to execute command");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user