Skip to content

Commit

Permalink
adds --show option to display password instead of copying to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
conradkleinespel committed Jul 17, 2016
1 parent 502bddd commit 3c9a480
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 104 deletions.
120 changes: 62 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rpassword = "0.2"
getopts = "0.2"
byteorder = "0.5"
clipboard = "0.1"
unix-daemonize = "0.1"
unix-daemonize = "0.1" # only needed for linux

[[bin]]
name = "rooster"
Expand Down
6 changes: 6 additions & 0 deletions src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ pub fn callback_exec(matches: &getopts::Matches, store: &mut password::v2::Passw
);
match store.add_password(password) {
Ok(_) => {
if matches.opt_present("show") {
println_ok!("Alright! Here is your password: {}", password_as_string_clipboard.deref());
return Ok(());
}

if copy_to_clipboard(password_as_string_clipboard.deref()).is_err() {
println_ok!("Alright! I've saved your new password for {}. Here it is, one more time: {}", app_name, password_as_string_clipboard.deref());
return Err(1);
}

println_ok!("Alright! I've saved your new password for {}. You can paste it anywhere with {}.", app_name, paste_keys());
},
Err(err) => {
Expand Down
6 changes: 6 additions & 0 deletions src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ pub fn callback_exec(matches: &getopts::Matches, store: &mut password::v2::Passw

match store.add_password(password) {
Ok(_) => {
if matches.opt_present("show") {
println_ok!("Alright! Here is your password: {}", password_as_string_clipboard.deref());
return Ok(());
}

if copy_to_clipboard(password_as_string_clipboard.deref()).is_err() {
println_ok!("Alright! I've saved your new password for {}. Here it is: {}", app_name, password_as_string_clipboard.deref());
return Err(1);
}

println_ok!("Alright! I've saved your new password for {}. You can paste it anywhere with {}.", app_name, paste_keys());
return Ok(());
},
Expand Down
6 changes: 6 additions & 0 deletions src/commands/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn callback_help() {
println!("");
println!("Example:");
println!(" rooster get youtube");
println!(" rooster get -s youtube");
}

pub fn callback_exec(matches: &getopts::Matches, store: &mut password::v2::PasswordStore) -> Result<(), i32> {
Expand All @@ -38,6 +39,11 @@ pub fn callback_exec(matches: &getopts::Matches, store: &mut password::v2::Passw

match store.get_password(app_name) {
Some(ref password) => {
if matches.opt_present("show") {
println_ok!("Alright! Here is your password: {}", password.password.deref());
return Ok(());
}

if copy_to_clipboard(password.password.deref()).is_err() {
println_err!("Alright! Here is your password: {}", password.password.deref());
return Err(1);
Expand Down
6 changes: 6 additions & 0 deletions src/commands/regenerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ pub fn callback_exec(matches: &getopts::Matches, store: &mut password::v2::Passw

match store.add_password(previous) {
Ok(_) => {
if matches.opt_present("show") {
println_ok!("Alright! Here is your password: {}", password_as_string_clipboard.deref());
return Ok(());
}

if copy_to_clipboard(password_as_string_clipboard.deref()).is_err() {
println_ok!("Alright! I've saved your new password for {}. Here it is: {}", app_name, password_as_string_clipboard.deref());
return Err(1);
}

println_ok!("Done! I've saved your new password for {}. You can paste it anywhere with {}.", app_name, paste_keys());
return Ok(());
},
Expand Down
Loading

0 comments on commit 3c9a480

Please sign in to comment.