Sha256: 6778a64b2f0f72cdcdabb5985c2927e23d016aad7726a68eed2151590e6bfc24

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Jets
  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("~", ".jetsrc"),
        desc: "Initialize the plugin command with previous defaults. Uses .jetsrc in your home directory by default."

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

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

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

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

        run_plugin_generator plugin_args
      end

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.12 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.11 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.10 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.9 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.8 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.7 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.6 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.5 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.4 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.3 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.2 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.1 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.0 lib/jets/commands/plugin/plugin_command.rb
jets-5.0.0.beta1 lib/jets/commands/plugin/plugin_command.rb