diff options
author | Jesse Luehrs <doy@tozt.net> | 2024-05-08 22:06:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-08 22:06:02 -0400 |
commit | 5f5dd37a7376b2351d76b09d4017eadfaa5e836a (patch) | |
tree | b109c0791a26b828094d405d92512fce68324277 | |
parent | c50a098fa92a3c64f240258f81654f4165b08580 (diff) | |
parent | 8dfbb68b22277e375df6d6e265588873509d1bc4 (diff) | |
download | rbw-5f5dd37a7376b2351d76b09d4017eadfaa5e836a.tar.gz rbw-5f5dd37a7376b2351d76b09d4017eadfaa5e836a.zip |
Merge pull request #169 from robertgzr/code-needle
Support UUIDs and URIs in code command
-rw-r--r-- | src/bin/rbw/commands.rs | 9 | ||||
-rw-r--r-- | src/bin/rbw/main.rs | 8 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 93c216b..557eed6 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -1018,7 +1018,7 @@ pub fn get( } pub fn code( - name: &str, + needle: &Needle, user: Option<&str>, folder: Option<&str>, clipboard: bool, @@ -1030,12 +1030,11 @@ pub fn code( let desc = format!( "{}{}", user.map_or_else(String::new, |s| format!("{s}@")), - name + needle ); - let (_, decrypted) = - find_entry(&db, &Needle::Name(name.to_string()), user, folder) - .with_context(|| format!("couldn't find entry for '{desc}'"))?; + let (_, decrypted) = find_entry(&db, needle, user, folder) + .with_context(|| format!("couldn't find entry for '{desc}'"))?; if let DecryptedData::Login { totp, .. } = decrypted.data { if let Some(totp) = totp { diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index eefa52a..2fb96bf 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -92,8 +92,8 @@ enum Opt { visible_alias = "totp" )] Code { - #[arg(help = "Name or UUID of the entry to display")] - name: String, + #[arg(help = "Name, URI or UUID of the entry to display", value_parser = commands::parse_needle)] + needle: commands::Needle, #[arg(help = "Username of the entry to display")] user: Option<String>, #[arg(long, help = "Folder name to search in")] @@ -340,12 +340,12 @@ fn main() { *clipboard, ), Opt::Code { - name, + needle, user, folder, clipboard, } => commands::code( - name, + needle, user.as_deref(), folder.as_deref(), *clipboard, |