diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-19 20:26:35 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-19 20:26:35 -0400 |
commit | 44f0f76c906d3fabe592958c208c0782a1d9305a (patch) | |
tree | 55079205aafcfcc3fdcaae7eb1323bc042b93a2f /src/bin/rbw/commands.rs | |
parent | ca2f934b014a733121d57475e793e0dad53f7aa9 (diff) | |
download | rbw-44f0f76c906d3fabe592958c208c0782a1d9305a.tar.gz rbw-44f0f76c906d3fabe592958c208c0782a1d9305a.zip |
allow creating entries with associated uris
Diffstat (limited to 'src/bin/rbw/commands.rs')
-rw-r--r-- | src/bin/rbw/commands.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 839dca3..2385163 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -129,7 +129,11 @@ pub fn get(name: &str, user: Option<&str>, full: bool) -> anyhow::Result<()> { Ok(()) } -pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { +pub fn add( + name: &str, + username: Option<&str>, + uris: Vec<&str>, +) -> anyhow::Result<()> { unlock()?; let email = config_email()?; @@ -154,6 +158,10 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { let notes = notes .map(|notes| crate::actions::encrypt(¬es)) .transpose()?; + let uris: Vec<String> = uris + .iter() + .map(|uri| crate::actions::encrypt(&uri)) + .collect::<anyhow::Result<_>>()?; if let (Some(access_token), ()) = rbw::actions::add( &access_token, @@ -162,6 +170,7 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { username.as_deref(), password.as_deref(), notes.as_deref(), + &uris, )? { db.access_token = Some(access_token); db.save(&email).context("failed to save database")?; @@ -175,6 +184,7 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { pub fn generate( name: Option<&str>, username: Option<&str>, + uris: Vec<&str>, len: usize, ty: rbw::pwgen::Type, ) -> anyhow::Result<()> { @@ -196,6 +206,10 @@ pub fn generate( .map(|username| crate::actions::encrypt(username)) .transpose()?; let password = crate::actions::encrypt(&password)?; + let uris: Vec<String> = uris + .iter() + .map(|uri| crate::actions::encrypt(&uri)) + .collect::<anyhow::Result<_>>()?; if let (Some(access_token), ()) = rbw::actions::add( &access_token, @@ -204,6 +218,7 @@ pub fn generate( username.as_deref(), Some(&password), None, + &uris, )? { db.access_token = Some(access_token); db.save(&email).context("failed to save database")?; |