Class: Trunk::CLI
- Inherits:
-
Thor
- Object
- Thor
- Trunk::CLI
- Defined in:
- lib/trunk/cli.rb
Instance Method Summary collapse
- #add(name, password = $stdin.gets.strip) ⇒ Object
- #setup ⇒ Object
- #show(name) ⇒ Object
- #version ⇒ Object
Instance Method Details
#add(name, password = $stdin.gets.strip) ⇒ Object
4 5 6 |
# File 'lib/trunk/cli.rb', line 4 def add(name, password = $stdin.gets.strip) storage.store(name, password) end |
#setup ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/trunk/cli.rb', line 22 def setup FileUtils.mkdir_p(dir) 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([:algorithm], passphrase)) FileUtils.touch(database_path) [database_path, private_key_path].each { |x| FileUtils.chmod(0600, x) } end |
#show(name) ⇒ Object
9 10 11 12 13 |
# File 'lib/trunk/cli.rb', line 9 def show(name) print storage.fetch(name) rescue OpenSSL::PKey::RSAError => error say error., :red end |