aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/agent.rs1
-rw-r--r--src/bin/agent.rs1
-rw-r--r--src/bin/rbw.rs13
3 files changed, 15 insertions, 0 deletions
diff --git a/src/agent.rs b/src/agent.rs
index c64acc9..1aec70c 100644
--- a/src/agent.rs
+++ b/src/agent.rs
@@ -14,6 +14,7 @@ pub enum Action {
// add
// update
// remove
+ Quit,
}
#[derive(serde::Serialize, serde::Deserialize, Debug)]
diff --git a/src/bin/agent.rs b/src/bin/agent.rs
index 9081988..96de0c2 100644
--- a/src/bin/agent.rs
+++ b/src/bin/agent.rs
@@ -140,6 +140,7 @@ async fn handle_sock(
rbw::agent::Action::Decrypt { cipherstring } => {
decrypt(&mut sock, state.clone(), &cipherstring).await
}
+ rbw::agent::Action::Quit => std::process::exit(0),
}
}
diff --git a/src/bin/rbw.rs b/src/bin/rbw.rs
index b309550..0cb9fe7 100644
--- a/src/bin/rbw.rs
+++ b/src/bin/rbw.rs
@@ -128,6 +128,17 @@ fn purge() {
todo!()
}
+fn stop_agent() {
+ let mut sock = connect();
+ send(
+ &mut sock,
+ &rbw::agent::Request {
+ tty: std::env::var("TTY").ok(),
+ action: rbw::agent::Action::Quit,
+ },
+ );
+}
+
fn main() {
let matches = clap::App::new("rbw")
.about("unofficial bitwarden cli")
@@ -144,6 +155,7 @@ fn main() {
.subcommand(clap::SubCommand::with_name("remove"))
.subcommand(clap::SubCommand::with_name("lock"))
.subcommand(clap::SubCommand::with_name("purge"))
+ .subcommand(clap::SubCommand::with_name("stop-agent"))
.get_matches();
ensure_agent();
@@ -160,6 +172,7 @@ fn main() {
("remove", Some(_)) => remove(),
("lock", Some(_)) => lock(),
("purge", Some(_)) => purge(),
+ ("stop-agent", Some(_)) => stop_agent(),
_ => unimplemented!(),
}
}