Sha256: 9e020273e4e94193bb87fc88cde9dc35016f1dd4b0a46b05ebc3295c183ec44e

Contents?: true

Size: 1.64 KB

Versions: 15

Compression:

Stored size: 1.64 KB

Contents

module Coherent
  module Commands  
  
    class List
      def initialize(base_command)
        @base_command = base_command
        @sources = []
        @local = false
        @remote = true
      end
    
      def options
        OptionParser.new do |o|
          o.set_summary_indent('  ')
          o.banner =    "Usage: #{@base_command.script_name} list [OPTIONS] [PATTERN]"
          o.define_head "List available plugins."
          o.separator   ""        
          o.separator   "Options:"
          o.separator   ""
          o.on(         "-s", "--source=URL1,URL2", Array,
                        "Use the specified plugin repositories.") {|sources| @sources = sources}
          o.on(         "--local", 
                        "List locally installed plugins.") {|local| @local, @remote = local, false}
          o.on(         "--remote",
                        "List remotely available plugins. This is the default behavior",
                        "unless --local is provided.") {|remote| @remote = remote}
        end
      end
    
      def parse!(args)
        options.order!(args)
        unless @sources.empty?
          @sources.map!{ |uri| Repository.new(uri) }
        else
          @sources = Repositories.instance.all
        end
        if @remote
          @sources.map{|r| r.plugins}.flatten.each do |plugin| 
            if @local or !plugin.installed?
              puts plugin.to_s
            end
          end
        else
          cd "#{@base_command.environment.root}/vendor/plugins"
          Dir["*"].select{|p| File.directory?(p)}.each do |name| 
            puts name
          end
        end
      end
    end



  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
coherent-0.6.11 lib/plugin/commands/list.rb
coherent-0.6.10 lib/plugin/commands/list.rb
coherent-0.6.9 lib/plugin/commands/list.rb
coherent-0.6.8 lib/plugin/commands/list.rb
coherent-0.6.7 lib/plugin/commands/list.rb
coherent-0.6.6 lib/plugin/commands/list.rb
coherent-0.6.5 lib/plugin/commands/list.rb
coherent-0.6.4 lib/plugin/commands/list.rb
coherent-0.6.2 lib/plugin/commands/list.rb
coherent-0.6.1 lib/plugin/commands/list.rb
coherent-0.6.0 lib/plugin/commands/list.rb
coherent-0.4.3 lib/plugin/commands/list.rb
coherent-0.4.2 lib/plugin/commands/list.rb
coherent-0.4.1 lib/plugin/commands/list.rb
coherent-0.4.0 lib/plugin/commands/list.rb