aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/rbw/commands.rs')
-rw-r--r--src/bin/rbw/commands.rs30
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(