Skip to content

Commit

Permalink
Merge pull request #169 from robertgzr/code-needle
Browse files Browse the repository at this point in the history
Support UUIDs and URIs in code command
  • Loading branch information
doy authored May 9, 2024
2 parents c50a098 + 8dfbb68 commit 5f5dd37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/bin/rbw/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ pub fn get(
}

pub fn code(
name: &str,
needle: &Needle,
user: Option<&str>,
folder: Option<&str>,
clipboard: bool,
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/bin/rbw/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5f5dd37

Please sign in to comment.