Sha256: d2d2a1e7be37e5ddd3605fcbda4d30be39960a35528c252ce35168d3f2344bcb

Contents?: true

Size: 1.73 KB

Versions: 7

Compression:

Stored size: 1.73 KB

Contents

module PowerStencil
  module CommandProcessors

    class Plugin

      include Climatic::Script::UnimplementedProcessor
      include Climatic::Proxy
      include PowerStencil::Project::Proxy

      def execute
        
        if config[:list]
          if project.plugins.empty?
            puts 'No plugin used in this project.'
          else
            puts "#{project.plugins.size} plugin#{project.plugins.size == 1 ? '' : 's'} found to be used in this project."
          end
          project.plugins.each do |plugin_name, plugin_def|
            puts " - #{plugin_name} (in '#{plugin_def.entry_point_path}')"
            if config[:verbose]
              plugin_def.capabilities.each do |name, value|
                puts "   #{name}: #{value}"
              end
            end
          end
          return
        end
        

        if config[:create]
          if config.command_line_layer.extra_parameters.empty?
            raise PowerStencil::Error, 'Please specify at least one plugin name !'
          end
          config.command_line_layer.extra_parameters.each do |plugin_name|
            begin
              target_path = File.join project.project_plugin_path(plugin_name)
              project.create_plugin_tree plugin_name, target_path
              puts "Generated new plugin '#{plugin_name}'"
            rescue => e
              msg = "Could not create plugin '#{plugin_name}' because '#{e.message}'"
              puts msg
              logger.error "Could not create plugin '#{plugin_name}' because '#{e.message}'"
              logger.debug PowerStencil::Error.report_error(e)
            end
          end
          return
        end

        raise PowerStencil::Error, 'You should specify an option'

      end

    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
power_stencil-0.5.1 lib/power_stencil/command_processors/plugin.rb
power_stencil-0.5.0 lib/power_stencil/command_processors/plugin.rb
power_stencil-0.4.22 lib/power_stencil/command_processors/plugin.rb
power_stencil-0.4.21 lib/power_stencil/command_processors/plugin.rb
power_stencil-0.4.20 lib/power_stencil/command_processors/plugin.rb
power_stencil-0.4.19 lib/power_stencil/command_processors/plugin.rb
power_stencil-0.4.18 lib/power_stencil/command_processors/plugin.rb