From 2feed7e2e9367c935aeb669daab66a63cff2f6c0 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 3 May 2020 16:01:26 -0400 Subject: add command to clear a config setting --- src/bin/rbw/commands.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/bin/rbw/commands.rs') 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()?; -- cgit v1.2.3-54-g00ecf