From 0402e161b1a3b69af3cc8ede2fcaf1c4855b601b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 18 Apr 2020 02:34:58 -0400 Subject: support adding entries with notes --- src/bin/rbw/commands.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/bin/rbw/commands.rs') diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index a42e796..3e2f241 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -148,18 +148,18 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { let password = lines.next().unwrap(); let password = crate::actions::encrypt(password)?; - let mut note: String = lines + let mut notes: String = lines .skip_while(|line| *line == "") .filter(|line| !line.starts_with('#')) .map(|line| format!("{}\n", line)) .collect(); - while note.ends_with('\n') { - note.pop(); + while notes.ends_with('\n') { + notes.pop(); } - let note = if note == "" { + let notes = if notes == "" { None } else { - Some(crate::actions::encrypt(¬e)?) + Some(crate::actions::encrypt(¬es)?) }; let cipher = rbw::api::Cipher { @@ -168,6 +168,7 @@ pub fn add(name: &str, username: Option<&str>) -> anyhow::Result<()> { username, password: Some(password), }, + notes, }; let res = rbw::actions::add(&access_token, &cipher); @@ -222,6 +223,7 @@ pub fn generate( username, password: Some(password), }, + notes: None, }; let res = rbw::actions::add(&access_token, &cipher); -- cgit v1.2.3-54-g00ecf