aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw/commands.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-05-03 16:01:26 -0400
committerJesse Luehrs <doy@tozt.net>2020-05-03 16:02:53 -0400
commit2feed7e2e9367c935aeb669daab66a63cff2f6c0 (patch)
tree17c20ca1a762c2bb2a017506dfdc1cda30a9c25b /src/bin/rbw/commands.rs
parentfbd23df0526996a6745895e8e5f2266f88e75e7e (diff)
downloadrbw-2feed7e2e9367c935aeb669daab66a63cff2f6c0.tar.gz
rbw-2feed7e2e9367c935aeb669daab66a63cff2f6c0.zip
add command to clear a config setting
Diffstat (limited to 'src/bin/rbw/commands.rs')
-rw-r--r--src/bin/rbw/commands.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index a6e98c7..a2e9f9d 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -75,6 +75,23 @@ pub fn config_set(key: &str, value: &str) -> anyhow::Result<()> {
Ok(())
}
+pub fn config_unset(key: &str) -> anyhow::Result<()> {
+ let mut config = rbw::config::Config::load()
+ .unwrap_or_else(|_| rbw::config::Config::new());
+ match key {
+ "email" => config.email = None,
+ "base_url" => config.base_url = None,
+ "identity_url" => config.identity_url = None,
+ "lock_timeout" => {
+ config.lock_timeout = rbw::config::default_lock_timeout()
+ }
+ _ => return Err(anyhow::anyhow!("invalid config key: {}", key)),
+ }
+ config.save().context("failed to save config file")?;
+
+ Ok(())
+}
+
pub fn login() -> anyhow::Result<()> {
ensure_agent()?;
crate::actions::login()?;