diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-18 02:34:58 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-18 02:34:58 -0400 |
commit | 0402e161b1a3b69af3cc8ede2fcaf1c4855b601b (patch) | |
tree | 0151b636301bd010c746b5b2730855ef30708f93 /src/bin/rbw/commands.rs | |
parent | 45343bb64d9230da0705d259c7f411d8af8d990f (diff) | |
download | rbw-0402e161b1a3b69af3cc8ede2fcaf1c4855b601b.tar.gz rbw-0402e161b1a3b69af3cc8ede2fcaf1c4855b601b.zip |
support adding entries with notes
Diffstat (limited to 'src/bin/rbw/commands.rs')
-rw-r--r-- | src/bin/rbw/commands.rs | 12 |
1 files changed, 7 insertions, 5 deletions
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); |