diff --git a/src/parser.rs b/src/parser.rs index 8a9ea1c..4a8b653 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -20,6 +20,7 @@ peg::parser! { / source_cmd() / enc_cmd() / pass_cmd() + / unpass_cmd() / noop_cmd() / comment_cmd() ) { c } @@ -84,6 +85,7 @@ peg::parser! { rule error_cmd() -> Command<'input> = "error" _ e:$(([' '..='~'])+) { Command::Error(LKErr::Error(e)) } rule mv_cmd() -> Command<'input> = "mv" _ name:word() _ folder:word() { Command::Mv(name, folder) } rule pass_cmd() -> Command<'input> = "pass" _ name:word() { Command::Pass(name) } + rule unpass_cmd() -> Command<'input> = "unpass" _ name:word() { Command::UnPass(name) } rule enc_cmd() -> Command<'input> = "enc" _ name:word() { Command::Enc(name) } rule rm_cmd() -> Command<'input> = "rm" _ name:word() { Command::Rm(name) } rule comment_cmd() -> Command<'input> = "comment" _ name:word() c:comment()? { Command::Comment(name, c) } diff --git a/src/repl.rs b/src/repl.rs index 27f3d0a..fa39e7e 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -314,6 +314,10 @@ impl<'a> LKEval<'a> { } } }, + Command::UnPass(name) => match self.state.borrow_mut().secrets.remove(name) { + Some(_) => out.push(format!("Removed saved password for {}", name)), + None => out.push(format!("error: saved password for {} not found", name)), + } Command::Noop => (), Command::Help => { out.push("HELP".to_string()); diff --git a/src/structs.rs b/src/structs.rs index 35e4416..a6650cd 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -36,6 +36,7 @@ pub enum Command<'a> { Rm(Name), Enc(Name), Pass(Name), + UnPass(Name), PasteBuffer(String), Source(String), Comment(Name, Comment),