Class: Credman::Get

Inherits:
Base
  • Object
show all
Defined in:
lib/credman/get.rb

Instance Method Summary collapse

Methods inherited from Base

#config_has_keys?, #configs, #decript, #initialize, #key_for, #pastel, #print_key_and_value, #rewrite_config_for

Constructor Details

This class inherits a constructor from Credman::Base

Instance Method Details

#perform(keys) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/credman/get.rb', line 3

def perform(keys)
  abort pastel.red("At least one key required") if keys.empty?

  keys_with_path = keys.index_with { |key| key.split(".").map(&:to_sym) }

  configs.each do |env, config|
    puts pastel.green("#{env}:")

    keys_with_path.each do |full_key, key_path|
      value = config_has_keys?(config, key_path) ? configs[env].dig(*key_path) : "not set"
      print_key_and_value(full_key, value)
    end
  end
end