diff options
Diffstat (limited to 'railties/lib/rails/command/environment_argument.rb')
-rw-r--r-- | railties/lib/rails/command/environment_argument.rb | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/railties/lib/rails/command/environment_argument.rb b/railties/lib/rails/command/environment_argument.rb index 5dc98b113d..0cb3f1ce1e 100644 --- a/railties/lib/rails/command/environment_argument.rb +++ b/railties/lib/rails/command/environment_argument.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "active_support" +require "active_support/core_ext/class/attribute" module Rails module Command @@ -8,26 +9,16 @@ module Rails extend ActiveSupport::Concern included do - argument :environment, optional: true, banner: "environment" - - class_option :environment, aliases: "-e", type: :string, - desc: "Specifies the environment to run this console under (test/development/production)." + class_attribute :environment_desc, default: "Specifies the environment to run this #{self.command_name} under (test/development/production)." + class_option :environment, aliases: "-e", type: :string, desc: environment_desc end private - def extract_environment_option_from_argument - if environment - self.options = options.merge(environment: acceptable_environment(environment)) - - ActiveSupport::Deprecation.warn "Passing the environment's name as a " \ - "regular argument is deprecated and " \ - "will be removed in the next Rails " \ - "version. Please, use the -e option " \ - "instead." - elsif options[:environment] + def extract_environment_option_from_argument(default_environment: Rails::Command.environment) + if options[:environment] self.options = options.merge(environment: acceptable_environment(options[:environment])) else - self.options = options.merge(environment: Rails::Command.environment) + self.options = options.merge(environment: default_environment) end end |