diff options
author | Robert Günzler <r@gnzler.io> | 2024-05-01 19:53:26 +0200 |
---|---|---|
committer | Robert Günzler <r@gnzler.io> | 2024-05-01 19:53:26 +0200 |
commit | 8dfbb68b22277e375df6d6e265588873509d1bc4 (patch) | |
tree | 558e471fc9111247595293d2531e99579e71cc9e /src/bin | |
parent | df5c9f1d2c869925cbfdddc8176f7d000e27a237 (diff) | |
download | rbw-8dfbb68b22277e375df6d6e265588873509d1bc4.tar.gz rbw-8dfbb68b22277e375df6d6e265588873509d1bc4.zip |
Support UUIDs and URIs in code command
a864366e60f6e7ae67df91010d7e30f3b1569ac0 changed the implementation of
`find_entry` to work on the new `Needle` type, but when calling into it from the
`code` subcommand the provided string was only passed as a `Needle::Name` when
in fact also UUIDs are allowed.
Remedy this by parsing the first argument in the same way as with the `get`
command, which also enables passing URIs
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'src/bin')
-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 3329f76..34d2d90 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, |