Add command unpass to forget saved password for a specific name.

This commit is contained in:
Oleksandr Kozachuk
2022-12-17 20:13:02 +01:00
parent 5ef5ef20ec
commit 573567928c
3 changed files with 7 additions and 0 deletions
+2
View File
@@ -20,6 +20,7 @@ peg::parser! {
/ source_cmd() / source_cmd()
/ enc_cmd() / enc_cmd()
/ pass_cmd() / pass_cmd()
/ unpass_cmd()
/ noop_cmd() / noop_cmd()
/ comment_cmd() / comment_cmd()
) { c } ) { c }
@@ -84,6 +85,7 @@ peg::parser! {
rule error_cmd() -> Command<'input> = "error" _ e:$(([' '..='~'])+) { Command::Error(LKErr::Error(e)) } 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 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 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 enc_cmd() -> Command<'input> = "enc" _ name:word() { Command::Enc(name) }
rule rm_cmd() -> Command<'input> = "rm" _ name:word() { Command::Rm(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) } rule comment_cmd() -> Command<'input> = "comment" _ name:word() c:comment()? { Command::Comment(name, c) }
+4
View File
@@ -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::Noop => (),
Command::Help => { Command::Help => {
out.push("HELP".to_string()); out.push("HELP".to_string());
+1
View File
@@ -36,6 +36,7 @@ pub enum Command<'a> {
Rm(Name), Rm(Name),
Enc(Name), Enc(Name),
Pass(Name), Pass(Name),
UnPass(Name),
PasteBuffer(String), PasteBuffer(String),
Source(String), Source(String),
Comment(Name, Comment), Comment(Name, Comment),