Parent

Commands::List

Public Class Methods

new(base_command) click to toggle source
# File lib/commands/plugin/commands.rb, line 125
def initialize(base_command)
  @base_command = base_command
  @sources = []
  @local = false
  @remote = false
  @cached = true
end

Public Instance Methods

options() click to toggle source
# File lib/commands/plugin/commands.rb, line 133
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| @remote = true; @cached = false }
    o.on(         "--local", 
                  "List locally installed plugins.") {|@local| @cached = false }
    o.on(         "--cached",
                  "List the known plugins in the local sources cache. This is the default behavior.") {|@cached|}
    o.on(         "--remote",
                  "List remotely available plugins.",
                  "unless --local is provided.") {|@remote| @cached = false }
  end
end
parse!(args) click to toggle source
# File lib/commands/plugin/commands.rb, line 153
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
  elsif @cached
    Repositories.instance.cached_plugins.each { |plugin| puts plugin.to_s }
    puts "\nThere are #{Repositories.instance.plugin_count} plugins in the source cache.\n\n"
  else
    cd "#{@base_command.environment.root}/vendor/plugins"
    Dir["*"].select{|p| File.directory?(p)}.each do |name| 
      puts name
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.