From 42c61bc627e16f3a5fa8fe80dddfce936c99d359 Mon Sep 17 00:00:00 2001 From: Tamar Ben-Shachar Date: Sat, 14 Dec 2013 18:28:00 -0800 Subject: [PATCH] generate new password automatically when using 'add' ...instead of having to copy/paste password output from generate command. --- Passwords.scala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Passwords.scala b/Passwords.scala index de4f2e7..c9387f5 100755 --- a/Passwords.scala +++ b/Passwords.scala @@ -181,7 +181,7 @@ object Passwords { } println("""|Commands: | generate [length] - | add + | add [length] | remove | list | search @@ -267,13 +267,10 @@ object Passwords { val (vault, db) = init(file, false) if (db.contains(login)) confirm("Overwrite existing entry? (Y/N): ") - val password = new String(System.console.readPassword("Password: ")) - val again = new String(System.console.readPassword("Confirm password: ")) - if (password != again) { - println("Passwords do not match.") - return - } + val length = if (args.length == 4) Integer.parseInt(args(3)) else 8 + val password = generate(length) vault.write(db + (login -> Password(password, System.currentTimeMillis))) + println("New password: " + password) case "remove" => if (args.length < 3) { usage()