aboutsummaryrefslogblamecommitdiffstats
path: root/railties/lib/rails/commands/initializers/initializers_command.rb
blob: bd2f3bed6770333dcf940ad64a3dcb0da1671b2e (plain) (tree)
1
2
3
4
5
6
7
8
9

                             

                                            


                                              

                                 
                                                                                                       
                 


                                                


                                                                  
                                                                




           
# frozen_string_literal: true

require "rails/command/environment_argument"

module Rails
  module Command
    class InitializersCommand < Base # :nodoc:
      include EnvironmentArgument

      desc "initializers", "Print out all defined initializers in the order they are invoked by Rails."
      def perform
        extract_environment_option_from_argument
        ENV["RAILS_ENV"] = options[:environment]

        require_application_and_environment!

        Rails.application.initializers.tsort_each do |initializer|
          say "#{initializer.context_class}.#{initializer.name}"
        end
      end
    end
  end
end