Class: Trunk::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/trunk/cli.rb

Instance Method Summary collapse

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

#setupObject



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(options[: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.message, :red
end

#versionObject



16
17
18
# File 'lib/trunk/cli.rb', line 16

def version
  say Trunk::VERSION
end