3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/credman/delete.rb', line 3
def perform(keys)
abort pastel.red("At least one key required") if keys.empty?
configs.each do |env, config|
puts pastel.green("#{env}:")
updated_config = config.dup
is_updated = false
keys_with_path = keys.index_with { |key| key.split(".").map(&:to_sym) }
keys_with_path.each do |full_key, key_path|
if config_has_keys?(config, key_path)
is_updated ||= true
deep_delete!(updated_config, key_path)
print pastel.blue("\t#{full_key}:\t"), pastel.green("✅ deleted\n")
else
print pastel.blue("\t#{full_key}:\t"), pastel.red("❌ key not found, can't delete\n")
end
end
rewrite_config_for(env, updated_config) if is_updated
end
end
|