diff options
Diffstat (limited to 'src/bin/rbw')
-rw-r--r-- | src/bin/rbw/actions.rs | 12 | ||||
-rw-r--r-- | src/bin/rbw/commands.rs | 15 | ||||
-rw-r--r-- | src/bin/rbw/main.rs | 17 |
3 files changed, 25 insertions, 19 deletions
diff --git a/src/bin/rbw/actions.rs b/src/bin/rbw/actions.rs index e0e1e55..39fde15 100644 --- a/src/bin/rbw/actions.rs +++ b/src/bin/rbw/actions.rs @@ -1,12 +1,12 @@ use anyhow::Context as _; use std::io::Read as _; -pub fn login(apikey: bool) -> anyhow::Result<()> { - if apikey { - simple_action(rbw::protocol::Action::LoginApiKey) - } else { - simple_action(rbw::protocol::Action::Login) - } +pub fn register() -> anyhow::Result<()> { + simple_action(rbw::protocol::Action::Register) +} + +pub fn login() -> anyhow::Result<()> { + 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 dddd501..9efd966 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -465,16 +465,23 @@ pub fn config_unset(key: &str) -> anyhow::Result<()> { Ok(()) } -pub fn login(apikey: bool) -> anyhow::Result<()> { +pub fn register() -> anyhow::Result<()> { ensure_agent()?; - crate::actions::login(apikey)?; + crate::actions::register()?; + + Ok(()) +} + +pub fn login() -> anyhow::Result<()> { + ensure_agent()?; + crate::actions::login()?; Ok(()) } pub fn unlock() -> anyhow::Result<()> { ensure_agent()?; - crate::actions::login(false)?; + crate::actions::login()?; crate::actions::unlock()?; Ok(()) @@ -489,7 +496,7 @@ pub fn unlocked() -> anyhow::Result<()> { pub fn sync() -> anyhow::Result<()> { ensure_agent()?; - crate::actions::login(false)?; + crate::actions::login()?; crate::actions::sync()?; Ok(()) diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index 2612398..0f2d13e 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -17,14 +17,11 @@ enum Opt { config: Config, }, + #[structopt(about = "Register this device with the Bitwarden server")] + Register, + #[structopt(about = "Log in to the Bitwarden server")] - 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, - }, + Login, #[structopt(about = "Unlock the local Bitwarden database")] Unlock, @@ -220,7 +217,8 @@ impl Opt { Self::Config { config } => { format!("config {}", config.subcommand_name()) } - Self::Login { .. } => "login".to_string(), + Self::Register => "register".to_string(), + Self::Login => "login".to_string(), Self::Unlock => "unlock".to_string(), Self::Unlocked => "unlocked".to_string(), Self::Sync => "sync".to_string(), @@ -290,7 +288,8 @@ fn main(opt: Opt) { Config::Set { key, value } => commands::config_set(key, value), Config::Unset { key } => commands::config_unset(key), }, - Opt::Login { apikey } => commands::login(*apikey), + Opt::Register => commands::register(), + Opt::Login => commands::login(), Opt::Unlock => commands::unlock(), Opt::Unlocked => commands::unlocked(), Opt::Sync => commands::sync(), |