Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UUIDs and URIs in code command #169

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading