Class: Duse::CLI::SecretUpdate

Inherits:
ApiCommand show all
Includes:
ShareWithUser, KeyHelper
Defined in:
lib/duse/cli/secret_update.rb

Instance Attribute Summary

Attributes inherited from Command

#arguments, #force_interactive, #input, #output

Instance Method Summary collapse

Methods included from KeyHelper

#choose_key, #choose_private_key_file, #ensure_matching_keys_for, #generate_key, #home_dir, #matching_keys?, #possible_ssh_keys, #private_key_for, #ssh_dir, #valid_ssh_private_key?

Methods inherited from ApiCommand

#execute, #setup

Methods inherited from Command

abstract, abstract?, #check_arity, #color, #command_name, command_name, #config, description, #error, #execute, #format, #full_command, full_command, has_subcommands?, has_super_command?, #help, #help_subcommands, #initialize, #interactive?, #parse, #say, #setup, skip, subcommand, subcommands, #success, super_command, super_command=, #terminal, #usage, #usage_for, #warn, #write_to, #wrong_args

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

This class inherits a constructor from Duse::CLI::Command

Instance Method Details

#run(secret_id = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/duse/cli/secret_update.rb', line 14

def run(secret_id = nil)
  secret_id ||= terminal.ask('Secret to update: ').to_i

  user = Duse::User.current
  ensure_matching_keys_for user
  private_key = config.private_key_for user
  secret = Duse::Secret.find secret_id
  print_secret secret, private_key
  secret_hash = Duse::Client::UpdateSecret.values(secret, values_to_update).encrypt_with(private_key).build

  response = Duse::Secret.update secret_id, secret_hash
  success 'Secret successfully updated!'
end