Class: Trustworthy::CLI::AddKey

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/trustworthy/cli/add_key.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

#default_options, #parse_options, #print_help, #say

Class Method Details

.descriptionObject



6
7
8
# File 'lib/trustworthy/cli/add_key.rb', line 6

def self.description
  'Add a new user key for a master key'
end

Instance Method Details

#run(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/trustworthy/cli/add_key.rb', line 10

def run(args)
  options = parse_options('add-key', args)

  say('Adding a new key to master key')

  prompt = Trustworthy::Prompt.new(options[:config_file], $terminal)
  master_key = prompt.unlock_master_key
  key = master_key.create_key
  username = prompt.add_user_key(key)

  say("Added #{username}")
end