Class: Commands::Source

Inherits:
Object show all
Defined in:
lib/commands/plugin.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_command) ⇒ Source

Returns a new instance of Source.



574
575
576
# File 'lib/commands/plugin.rb', line 574

def initialize(base_command)
  @base_command = base_command
end

Instance Method Details

#optionsObject



578
579
580
581
582
583
584
# File 'lib/commands/plugin.rb', line 578

def options
  OptionParser.new do |o|
    o.set_summary_indent('  ')
    o.banner =    "Usage: #{@base_command.script_name} source REPOSITORY [REPOSITORY [REPOSITORY]...]"
    o.define_head "Add new repositories to the default search list."
  end
end

#parse!(args) ⇒ Object



586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/commands/plugin.rb', line 586

def parse!(args)
  options.parse!(args)
  count = 0
  args.each do |uri|
    if Repositories.instance.add(uri)
      puts "added: #{uri.ljust(50)}" if $verbose
      count += 1
    else
      puts "failed: #{uri.ljust(50)}"
    end
  end
  Repositories.instance.save
  puts "Added #{count} repositories."
end