aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-07-25 04:33:51 -0400
committerJesse Luehrs <doy@tozt.net>2020-07-25 04:33:51 -0400
commit6b38682d711fb74feddcc06c4da18f8e771858df (patch)
tree52c36bba21247f0abb7062f87e3e0745dd496b4f /src/bin/rbw
parent56e9b720bade5dcdc6505952c1bf81bdeca26bcd (diff)
downloadrbw-6b38682d711fb74feddcc06c4da18f8e771858df.tar.gz
rbw-6b38682d711fb74feddcc06c4da18f8e771858df.zip
implement rbw unlocked
Diffstat (limited to 'src/bin/rbw')
-rw-r--r--src/bin/rbw/actions.rs4
-rw-r--r--src/bin/rbw/commands.rs7
-rw-r--r--src/bin/rbw/main.rs5
3 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/rbw/actions.rs b/src/bin/rbw/actions.rs
index 9e64bbf..2c7d699 100644
--- a/src/bin/rbw/actions.rs
+++ b/src/bin/rbw/actions.rs
@@ -10,6 +10,10 @@ pub fn unlock() -> anyhow::Result<()> {
simple_action(rbw::protocol::Action::Unlock)
}
+pub fn unlocked() -> anyhow::Result<()> {
+ simple_action(rbw::protocol::Action::CheckLock)
+}
+
pub fn sync() -> anyhow::Result<()> {
simple_action(rbw::protocol::Action::Sync)
}
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index e5858b6..f514153 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -466,6 +466,13 @@ pub fn unlock() -> anyhow::Result<()> {
Ok(())
}
+pub fn unlocked() -> anyhow::Result<()> {
+ ensure_agent()?;
+ crate::actions::unlocked()?;
+
+ Ok(())
+}
+
pub fn sync() -> anyhow::Result<()> {
ensure_agent()?;
crate::actions::login()?;
diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs
index f1903e7..2bb4360 100644
--- a/src/bin/rbw/main.rs
+++ b/src/bin/rbw/main.rs
@@ -22,6 +22,9 @@ enum Opt {
#[structopt(about = "Unlock the local Bitwarden database")]
Unlock,
+ #[structopt(about = "Check if the local Bitwarden database is unlocked")]
+ Unlocked,
+
#[structopt(about = "Update the local copy of the Bitwarden database")]
Sync,
@@ -207,6 +210,7 @@ impl Opt {
}
Self::Login => "login".to_string(),
Self::Unlock => "unlock".to_string(),
+ Self::Unlocked => "unlocked".to_string(),
Self::Sync => "sync".to_string(),
Self::List { .. } => "list".to_string(),
Self::Get { .. } => "get".to_string(),
@@ -275,6 +279,7 @@ fn main(opt: Opt) {
},
Opt::Login => commands::login(),
Opt::Unlock => commands::unlock(),
+ Opt::Unlocked => commands::unlocked(),
Opt::Sync => commands::sync(),
Opt::List { fields } => commands::list(&fields),
Opt::Get {