Change commands to not depend on ARGV

Follow-up to #38463.

This commit changes additional command classes to not depend on prior
ARGV contents.
This commit is contained in:
Jonathan Hefner 2020-02-17 23:59:23 -06:00
parent 51d73fb84b
commit 373ad2c624
3 changed files with 10 additions and 6 deletions

@ -10,8 +10,13 @@ module System
class ChangeCommand < Base # :nodoc: class ChangeCommand < Base # :nodoc:
class_option :to, desc: "The database system to switch to." class_option :to, desc: "The database system to switch to."
def initialize(positional_args, option_args, *)
@argv = positional_args + option_args
super
end
def perform def perform
Rails::Generators::Db::System::ChangeGenerator.start Rails::Generators::Db::System::ChangeGenerator.start(@argv)
end end
end end
end end

@ -29,8 +29,8 @@ def help
def perform(*) def perform(*)
$LOAD_PATH << Rails::Command.root.join("test").to_s $LOAD_PATH << Rails::Command.root.join("test").to_s
Rails::TestUnit::Runner.parse_options(ARGV) Rails::TestUnit::Runner.parse_options(args)
Rails::TestUnit::Runner.run(ARGV) Rails::TestUnit::Runner.run(args)
end end
end end
end end

@ -123,9 +123,8 @@ def api_only!
template_engine: nil template_engine: nil
) )
if ARGV.first == "mailer" options[:mailer] ||= {}
options[:rails][:template_engine] = :erb options[:mailer][:template_engine] ||= :erb
end
end end
# Returns an array of generator namespaces that are hidden. # Returns an array of generator namespaces that are hidden.