Class: Duse::CLI::SecretGet
- Inherits:
-
ApiCommand
- Object
- Command
- ApiCommand
- Duse::CLI::SecretGet
- Includes:
- KeyHelper
- Defined in:
- lib/duse/cli/secret_get.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
Methods inherited from Command
abstract, abstract?, #color, command_name, #command_name, #config, description, #error, #execute, #full_command, full_command, has_subcommands?, has_super_command?, #help, #help_subcommands, #initialize, #interactive?, #parse, #say, skip, subcommand, subcommands, #success, super_command, super_command=, #terminal, #usage, #usage_for, #warn, #write_to
Methods included from Parser
Constructor Details
This class inherits a constructor from Duse::CLI::Command
Instance Method Details
#print_secret(secret) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/duse/cli/secret_get.rb', line 20 def print_secret(secret) user = Duse::User.current ensure_matching_keys_for user private_key = config.private_key_for user plain_secret = secret.decrypt(private_key) if plain? print plain_secret $stdout.flush return end say " Name: #{secret.title} Secret: #{plain_secret} Access: #{secret.users.map(&:username).join(', ')} ".gsub(/^( |\t)+/, "") end |
#run(secret_id = nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/duse/cli/secret_get.rb', line 13 def run(secret_id = nil) secret_id ||= terminal.ask('Secret to retrieve: ').to_i secret = Duse::Secret.find secret_id print_secret(secret) end |