module Rails::Command::EnvironmentArgument
def acceptable_environment(env = nil)
def acceptable_environment(env = nil) if available_environments.include? env env else %w( production development test ).detect { |e| /^#{env}/.match?(e) } || env end end
def available_environments
def available_environments Dir["config/environments/*.rb"].map { |fname| File.basename(fname, ".*") } end
def extract_environment_option_from_argument(default_environment: Rails::Command.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: default_environment) end end