Class: Rails::Command::CredentialsCommand

Inherits:
Base
  • Object
show all
Includes:
EnvironmentArgument, Helpers::Editor
Defined in:
lib/rails/commands/credentials/credentials_command.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

banner, base_name, command_name, default_command_root, desc, engine?, executable, exit_on_failure?, #help, hide_command!, inherited, namespace, perform, printing_commands, usage_path

Methods included from Actions

#load_generators, #load_tasks, #require_application!, #require_application_and_environment!, #require_environment!, #set_application_directory!

Instance Method Details

#editObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rails/commands/credentials/credentials_command.rb', line 23

def edit
  extract_environment_option_from_argument(default_environment: nil)
  require_application!

  ensure_editor_available(command: "bin/rails credentials:edit") || (return)

  ensure_encryption_key_has_been_added if credentials.key.nil?
  ensure_credentials_have_been_added

  catch_editing_exceptions do
    change_credentials_in_system_editor
  end

  say "File encrypted and saved."
rescue ActiveSupport::MessageEncryptor::InvalidMessage
  say "Couldn't decrypt #{content_path}. Perhaps you passed the wrong key?"
end

#showObject



41
42
43
44
45
46
# File 'lib/rails/commands/credentials/credentials_command.rb', line 41

def show
  extract_environment_option_from_argument(default_environment: nil)
  require_application!

  say credentials.read.presence || missing_credentials_message
end