aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2024-04-20 14:58:42 -0400
committerJesse Luehrs <doy@tozt.net>2024-04-20 14:58:42 -0400
commit52cd14086afbfae2a0ad26254c69508badbfbd67 (patch)
tree8d0dcaae66be658a55cbd8b062ca4b080e546b06
parente9c45e642bad7b56b2f95d0441ddce913455f204 (diff)
downloadrbw-52cd14086afbfae2a0ad26254c69508badbfbd67.tar.gz
rbw-52cd14086afbfae2a0ad26254c69508badbfbd67.zip
add --clipboard to rbw code
-rw-r--r--src/bin/rbw/commands.rs3
-rw-r--r--src/bin/rbw/main.rs16
2 files changed, 15 insertions, 4 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 02ab63c..703a351 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -1025,6 +1025,7 @@ pub fn code(
name: &str,
user: Option<&str>,
folder: Option<&str>,
+ clipboard: bool,
) -> anyhow::Result<()> {
unlock()?;
@@ -1042,7 +1043,7 @@ pub fn code(
if let DecryptedData::Login { totp, .. } = decrypted.data {
if let Some(totp) = totp {
- println!("{}", generate_totp(&totp)?);
+ val_display_or_store(clipboard, &generate_totp(&totp)?);
} else {
return Err(anyhow::anyhow!(
"entry does not contain a totp secret"
diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs
index c0f623e..05dfa2b 100644
--- a/src/bin/rbw/main.rs
+++ b/src/bin/rbw/main.rs
@@ -95,6 +95,8 @@ enum Opt {
user: Option<String>,
#[arg(long, help = "Folder name to search in")]
folder: Option<String>,
+ #[structopt(long, help = "Copy result to clipboard")]
+ clipboard: bool,
},
#[command(
@@ -334,9 +336,17 @@ fn main() {
*raw,
*clipboard,
),
- Opt::Code { name, user, folder } => {
- commands::code(name, user.as_deref(), folder.as_deref())
- }
+ Opt::Code {
+ name,
+ user,
+ folder,
+ clipboard,
+ } => commands::code(
+ name,
+ user.as_deref(),
+ folder.as_deref(),
+ *clipboard,
+ ),
Opt::Add {
name,
user,