Class: Commands::List
Instance Method Summary collapse
-
#initialize(base_command) ⇒ List
constructor
A new instance of List.
- #options ⇒ Object
- #parse!(args) ⇒ Object
Constructor Details
#initialize(base_command) ⇒ List
Returns a new instance of List.
540 541 542 543 544 545 |
# File 'lib/commands/plugin.rb', line 540 def initialize(base_command) @base_command = base_command @sources = [] @local = false @remote = true end |
Instance Method Details
#options ⇒ Object
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/commands/plugin.rb', line 547 def OptionParser.new do |o| o.set_summary_indent(' ') o. = "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 |
#parse!(args) ⇒ Object
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/commands/plugin.rb', line 565 def parse!(args) .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 |