aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-04-10 03:12:48 -0400
committerJesse Luehrs <doy@tozt.net>2020-04-10 03:12:48 -0400
commit9f7e2803df80e1f6e446c638dca2f884c965a821 (patch)
tree03872e81096fee84dd88bea31338539117d85222 /src/bin/rbw.rs
parentb3a04c4a143c34ba92008cf018eed159f87a0c6e (diff)
downloadrbw-9f7e2803df80e1f6e446c638dca2f884c965a821.tar.gz
rbw-9f7e2803df80e1f6e446c638dca2f884c965a821.zip
save sync data to local file
Diffstat (limited to 'src/bin/rbw.rs')
-rw-r--r--src/bin/rbw.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/bin/rbw.rs b/src/bin/rbw.rs
index 3aae676..24ac1ad 100644
--- a/src/bin/rbw.rs
+++ b/src/bin/rbw.rs
@@ -68,6 +68,7 @@ fn login() {
action: rbw::agent::Action::Login,
},
);
+
let res = recv(&mut sock);
match res {
rbw::agent::Response::Ack => (),
@@ -89,6 +90,7 @@ fn unlock() {
action: rbw::agent::Action::Unlock,
},
);
+
let res = recv(&mut sock);
match res {
rbw::agent::Response::Ack => (),
@@ -110,6 +112,7 @@ fn sync() {
action: rbw::agent::Action::Sync,
},
);
+
let res = recv(&mut sock);
match res {
rbw::agent::Response::Ack => (),
@@ -123,7 +126,31 @@ fn sync() {
fn list() {
ensure_agent();
- todo!()
+ let email = config_email();
+ let db = rbw::db::Db::load(&email).unwrap_or_else(|_| rbw::db::Db::new());
+ for cipher in db.ciphers {
+ let mut sock = connect();
+ send(
+ &mut sock,
+ &rbw::agent::Request {
+ tty: std::env::var("TTY").ok(),
+ action: rbw::agent::Action::Decrypt {
+ cipherstring: cipher.name,
+ },
+ },
+ );
+
+ let res = recv(&mut sock);
+ match res {
+ rbw::agent::Response::Decrypt { plaintext } => {
+ println!("{}", plaintext);
+ }
+ rbw::agent::Response::Error { error } => {
+ panic!("failed to login: {}", error)
+ }
+ _ => panic!("unexpected message: {:?}", res),
+ }
+ }
}
fn get() {
@@ -175,6 +202,11 @@ fn stop_agent() {
);
}
+fn config_email() -> String {
+ let config = rbw::config::Config::load().unwrap();
+ config.email.unwrap()
+}
+
fn main() {
let matches = clap::App::new("rbw")
.about("unofficial bitwarden cli")