diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-04-19 21:30:52 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-04-19 21:30:52 -0400 |
commit | 7a32c43713514c02f783d3c8e0835229e7f59a83 (patch) | |
tree | 938779384d21d1c5a3874a55e12288e6e5669b66 /src/bin | |
parent | f949f04a3995e24b8a05a2323426eb69cdb1b922 (diff) | |
download | rbw-7a32c43713514c02f783d3c8e0835229e7f59a83.tar.gz rbw-7a32c43713514c02f783d3c8e0835229e7f59a83.zip |
allow selecting entries by id as well
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/rbw/commands.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index ff267eb..317d62b 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -436,15 +436,27 @@ fn find_entry( name: &str, username: Option<&str>, ) -> anyhow::Result<(rbw::db::Entry, DecryptedCipher)> { - let ciphers: Vec<(rbw::db::Entry, DecryptedCipher)> = db - .entries - .iter() - .cloned() - .map(|entry| { - decrypt_cipher(&entry).map(|decrypted| (entry, decrypted)) - }) - .collect::<anyhow::Result<_>>()?; - find_entry_raw(&ciphers, name, username) + match uuid::Uuid::parse_str(name) { + Ok(_) => { + for cipher in &db.entries { + if name == cipher.id { + return Ok((cipher.clone(), decrypt_cipher(&cipher)?)); + } + } + Err(anyhow::anyhow!("no entry found")) + } + Err(_) => { + let ciphers: Vec<(rbw::db::Entry, DecryptedCipher)> = db + .entries + .iter() + .cloned() + .map(|entry| { + decrypt_cipher(&entry).map(|decrypted| (entry, decrypted)) + }) + .collect::<anyhow::Result<_>>()?; + find_entry_raw(&ciphers, name, username) + } + } } fn find_entry_raw( |