From c801b232bcb5d885e846e33e26becd33631b8c5b Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Mon, 4 Mar 2019 08:12:05 +0900 Subject: Properly expand the environment's name in all commands Since 3777701f1380f3814bd5313b225586dec64d4104, the environment's name is automatically expanded in console and dbconsole commands. In order to match the behavior between the commands, fixes it to have the same behavior of all the commands. This behavior is defined in `EnvironmentArgument`. Since `EnvironmentArgument` also defines the environment option, it is reused. However, since desc was not content that can be used in all comments, fixed desc to be defined for each command. --- railties/lib/rails/commands/runner/runner_command.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails/commands/runner') diff --git a/railties/lib/rails/commands/runner/runner_command.rb b/railties/lib/rails/commands/runner/runner_command.rb index cb693bcf34..40fb5e4d89 100644 --- a/railties/lib/rails/commands/runner/runner_command.rb +++ b/railties/lib/rails/commands/runner/runner_command.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true +require "rails/command/environment_argument" + module Rails module Command class RunnerCommand < Base # :nodoc: - class_option :environment, aliases: "-e", type: :string, - default: Rails::Command.environment.dup, - desc: "The environment for the runner to operate under (test/development/production)" + include EnvironmentArgument + + self.environment_desc = "The environment for the runner to operate under (test/development/production)" no_commands do def help @@ -19,6 +21,8 @@ module Rails end def perform(code_or_file = nil, *command_argv) + extract_environment_option_from_argument + unless code_or_file help exit 1 -- cgit v1.2.3