diff options
Diffstat (limited to 'src/bin/rbw')
-rw-r--r-- | src/bin/rbw/actions.rs | 8 | ||||
-rw-r--r-- | src/bin/rbw/commands.rs | 8 | ||||
-rw-r--r-- | src/bin/rbw/main.rs | 12 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/bin/rbw/actions.rs b/src/bin/rbw/actions.rs index 75703f9..e0e1e55 100644 --- a/src/bin/rbw/actions.rs +++ b/src/bin/rbw/actions.rs @@ -1,8 +1,12 @@ use anyhow::Context as _; use std::io::Read as _; -pub fn login() -> anyhow::Result<()> { - simple_action(rbw::protocol::Action::Login) +pub fn login(apikey: bool) -> anyhow::Result<()> { + if apikey { + simple_action(rbw::protocol::Action::LoginApiKey) + } else { + simple_action(rbw::protocol::Action::Login) + } } pub fn unlock() -> anyhow::Result<()> { diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index db385a8..dddd501 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -465,16 +465,16 @@ pub fn config_unset(key: &str) -> anyhow::Result<()> { Ok(()) } -pub fn login() -> anyhow::Result<()> { +pub fn login(apikey: bool) -> anyhow::Result<()> { ensure_agent()?; - crate::actions::login()?; + crate::actions::login(apikey)?; Ok(()) } pub fn unlock() -> anyhow::Result<()> { ensure_agent()?; - crate::actions::login()?; + crate::actions::login(false)?; crate::actions::unlock()?; Ok(()) @@ -489,7 +489,7 @@ pub fn unlocked() -> anyhow::Result<()> { pub fn sync() -> anyhow::Result<()> { ensure_agent()?; - crate::actions::login()?; + crate::actions::login(false)?; crate::actions::sync()?; Ok(()) diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index e6e1249..2612398 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -18,7 +18,13 @@ enum Opt { }, #[structopt(about = "Log in to the Bitwarden server")] - Login, + Login { + #[structopt( + long, + help = "Log in to the Bitwarden server using your user API key (see https://bitwarden.com/help/article/personal-api-key/)" + )] + apikey: bool, + }, #[structopt(about = "Unlock the local Bitwarden database")] Unlock, @@ -214,7 +220,7 @@ impl Opt { Self::Config { config } => { format!("config {}", config.subcommand_name()) } - Self::Login => "login".to_string(), + Self::Login { .. } => "login".to_string(), Self::Unlock => "unlock".to_string(), Self::Unlocked => "unlocked".to_string(), Self::Sync => "sync".to_string(), @@ -284,7 +290,7 @@ fn main(opt: Opt) { Config::Set { key, value } => commands::config_set(key, value), Config::Unset { key } => commands::config_unset(key), }, - Opt::Login => commands::login(), + Opt::Login { apikey } => commands::login(*apikey), Opt::Unlock => commands::unlock(), Opt::Unlocked => commands::unlocked(), Opt::Sync => commands::sync(), |