Sha256: 3332c6dc1ff2c755f5309abb535e35a22a56a47fb27eddbd82fc40f4f450ef06

Contents?: true

Size: 1.26 KB

Versions: 20

Compression:

Stored size: 1.26 KB

Contents

module Rails
  module Command
    class PluginCommand < Base # :nodoc:
      hide_command!

      def help
        run_plugin_generator %w( --help )
      end

      def self.banner(*) # :nodoc:
        "#{executable} new [options]"
      end

      class_option :rc, type: :string, default: File.join("~", ".railsrc"),
        desc: "Initialize the plugin command with previous defaults. Uses .railsrc in your home directory by default."

      class_option :no_rc, desc: "Skip evaluating .railsrc."

      def perform(type = nil, *plugin_args)
        plugin_args << "--help" unless type == "new"

        unless options.key?("no_rc") # Thor's not so indifferent access hash.
          railsrc = File.expand_path(options[:rc])

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

        run_plugin_generator plugin_args
      end

      private
        def run_plugin_generator(plugin_args)
          require "rails/generators"
          require "rails/generators/rails/plugin/plugin_generator"
          Rails::Generators::PluginGenerator.start plugin_args
        end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
railties-5.1.7 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.7.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.6.2 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.6.1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.6 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.5 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.5.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.4 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.4.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.3 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.3.rc3 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.3.rc2 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.3.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.2 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.2.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.0 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.0.rc2 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.0.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.1.0.beta1 lib/rails/commands/plugin/plugin_command.rb