Class: Arcanus::Command::Show

Inherits:
Base
  • Object
show all
Includes:
Arcanus::Command::Shared::EnsureKey
Defined in:
lib/arcanus/command/show.rb

Instance Method Summary collapse

Methods included from Arcanus::Command::Shared::EnsureKey

#ensure_key_unlocked

Methods inherited from Base

description, #execute_command, from_arguments, #initialize, #run, short_name

Methods included from Utils

camel_case, deep_dup, snake_case

Constructor Details

This class inherits a constructor from Arcanus::Command::Base

Instance Method Details

#executeObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/arcanus/command/show.rb', line 9

def execute
  ensure_key_unlocked

  key = Arcanus::Key.from_file(repo.unlocked_key_path)
  chest = Arcanus::Chest.new(key: key, chest_file_path: repo.chest_file_path)

  if arguments.size > 1
    # Print specific key
    value = chest.get(arguments[1])
    if value.is_a?(Hash)
      output_colored_hash(value)
    else
      ui.print value
    end
  else
    # Print entire hash
    output_colored_hash(chest.to_hash)
  end
end