aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/generate/generate_command.rb
blob: 2718b453a8a9ec8ae536242a1ba9b9b9bc95756e (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
25
26
require "rails/generators"

module Rails
  module Command
    class GenerateCommand < Base # :nodoc:
      def help
        require_application_and_environment!
        load_generators

        Rails::Generators.help self.class.command_name
      end

      def perform(*)
        generator = args.shift
        return help unless generator

        require_application_and_environment!
        load_generators

        ARGV.shift

        Rails::Generators.invoke generator, args, behavior: :invoke, destination_root: Rails::Command.root
      end
    end
  end
end