Sha256: c841fc1ad0c4da637e0556091bedc7b0d6b0b7547ff4ee616dee6b6d9e87a15a

Contents?: true

Size: 1.29 KB

Versions: 42

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

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

42 entries across 42 versions & 3 rubygems

Version Path
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
spiral_form-0.1.1 vendor/bundle/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
spiral_form-0.1.0 vendor/bundle/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/commands/plugin/plugin_command.rb
railties-5.2.3 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.3.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.2.1 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.2 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.2.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.1.1 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.1 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.1.rc1 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.0 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.0.rc2 lib/rails/commands/plugin/plugin_command.rb
railties-5.2.0.rc1 lib/rails/commands/plugin/plugin_command.rb