Class: SecretKeysRails::Commands::SecretKeysCommand

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/secret_keys_rails/commands/secret_keys_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/secret_keys_rails/commands/secret_keys_command.rb', line 13

def self.exit_on_failure?
  true
end

.rake_argsObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/secret_keys_rails/commands/secret_keys_command.rb', line 17

def self.rake_args
  args = ARGV.dup
  if args[0]
    args[0] = args[0].sub(/\Asecret_keys:/, "")
  end
  if args[1] == "--"
    args.delete_at(1)
  end
  args
end

Instance Method Details

#editObject



39
40
41
42
43
44
45
46
47
# File 'lib/secret_keys_rails/commands/secret_keys_command.rb', line 39

def edit
  key = ensure_key(options["environment"])
  ensure_secrets(key, options["environment"])
  edit_secrets(options["environment"])

rescue SecretKeysRails::Error => e
  STDERR.puts e.message
  exit 1
end

#showObject



29
30
31
32
33
34
35
36
# File 'lib/secret_keys_rails/commands/secret_keys_command.rb', line 29

def show
  SecretKeysRails.require_encryption_key = true
  secrets = SecretKeysRails.read(options["environment"])
  STDOUT.write(yaml_dump(secrets.to_h))
rescue SecretKeysRails::Error => e
  STDERR.puts e.message
  exit 1
end