Class: Coherent::Commands::Unsource

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

Instance Method Summary collapse

Constructor Details

#initialize(base_command) ⇒ Unsource

Returns a new instance of Unsource.



5
6
7
# File 'lib/plugin/commands/unsource.rb', line 5

def initialize(base_command)
  @base_command = base_command
end

Instance Method Details

#optionsObject



9
10
11
12
13
14
15
16
17
# File 'lib/plugin/commands/unsource.rb', line 9

def options
  OptionParser.new do |o|
    o.set_summary_indent('  ')
    o.banner =    "Usage: #{@base_command.script_name} unsource URI [URI [URI]...]"
    o.define_head "Remove repositories from the default search list."
    o.separator ""
    o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
  end
end

#parse!(args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/plugin/commands/unsource.rb', line 19

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