aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/plugin.rb
blob: 56413aa7b07cbb3b674dbed353d76524055a9e3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if ARGV.first != "new"
  ARGV[0] = "--help"
else
  ARGV.shift
  unless ARGV.delete("--no-rc")
    customrc = ARGV.index{ |x| x.include?("--rc=") }
    railsrc = if customrc
      File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
    else
      File.join(File.expand_path("~"), ".railsrc")
    end

    if File.exist?(railsrc)
      extra_args_string = File.read(railsrc)
      extra_args = extra_args_string.split(/\n+/).flat_map(&:split)
      puts "Using #{extra_args.join(" ")} from #{railsrc}"
      ARGV.insert(1, *extra_args)
    end
  end
end

require "rails/generators"
require "rails/generators/rails/plugin/plugin_generator"
Rails::Generators::PluginGenerator.start