Sha256: 267ad49e7386b35981c0895e7d3b15f1b330015c05b4e1aeb4da07200064e930

Contents?: true

Size: 1.31 KB

Versions: 39

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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

      self.bin = "rails"

      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)
            say "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

39 entries across 39 versions & 5 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/railties-7.1.3.4/lib/rails/commands/plugin/plugin_command.rb
railties-8.0.1 lib/rails/commands/plugin/plugin_command.rb
railties-8.0.0.1 lib/rails/commands/plugin/plugin_command.rb
railties-7.2.2.1 lib/rails/commands/plugin/plugin_command.rb
railties-7.1.5.1 lib/rails/commands/plugin/plugin_command.rb
railties-8.0.0 lib/rails/commands/plugin/plugin_command.rb
railties-7.2.2 lib/rails/commands/plugin/plugin_command.rb
railties-7.1.5 lib/rails/commands/plugin/plugin_command.rb
railties-8.0.0.rc2 lib/rails/commands/plugin/plugin_command.rb
railties-7.2.1.2 lib/rails/commands/plugin/plugin_command.rb
railties-7.1.4.2 lib/rails/commands/plugin/plugin_command.rb
railties-8.0.0.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-7.2.1.1 lib/rails/commands/plugin/plugin_command.rb
railties-7.1.4.1 lib/rails/commands/plugin/plugin_command.rb
railties-8.0.0.beta1 lib/rails/commands/plugin/plugin_command.rb
omg-railties-8.0.0.alpha9 lib/rails/commands/plugin/plugin_command.rb
omg-railties-8.0.0.alpha8 lib/rails/commands/plugin/plugin_command.rb
omg-railties-8.0.0.alpha7 lib/rails/commands/plugin/plugin_command.rb
omg-railties-8.0.0.alpha4 lib/rails/commands/plugin/plugin_command.rb
omg-railties-8.0.0.alpha3 lib/rails/commands/plugin/plugin_command.rb