diff options
| author | mo <mo.khan@gmail.com> | 2018-06-13 19:46:11 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2018-06-13 19:46:11 -0600 |
| commit | 4563aea263ec5b6433f4b26dcf4d3c7eedeff34c (patch) | |
| tree | ca710293c3ad50718d156d8ce483200f9544b691 /lib | |
| parent | cef776a2483cac92c03f344ccf316c609aef3b1e (diff) | |
use builtin file_collision.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/trunk/cli.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/trunk/cli.rb b/lib/trunk/cli.rb index d06a5d5..e589d8d 100644 --- a/lib/trunk/cli.rb +++ b/lib/trunk/cli.rb @@ -1,7 +1,7 @@ module Trunk class CLI < Thor desc "add NAME PASSWORD", "add a key and password" - def add(name, password) + def add(name, password = ask?("password:", echo: false)) storage.store(name, password) end @@ -21,7 +21,7 @@ module Trunk method_option :algorithm, type: :string, default: 'AES-256-CBC' def setup FileUtils.mkdir_p(dir) - exit(0) unless yes?("Private key already exists. Overwrite?", :yellow) if File.exist?(private_key_path) + exit(0) unless file_collision(private_key_path) if File.exist?(private_key_path) IO.write(private_key_path, OpenSSL::PKey::RSA.new(4096).export(options[:algorithm], passphrase)) FileUtils.touch(database_path) [database_path, private_key_path].each { |x| FileUtils.chmod(0600, x) } |
