Class: Coherent::Commands::Source
- Inherits:
-
Object
- Object
- Coherent::Commands::Source
- Defined in:
- lib/plugin/commands/source.rb
Instance Method Summary collapse
-
#initialize(base_command) ⇒ Source
constructor
A new instance of Source.
- #options ⇒ Object
- #parse!(args) ⇒ Object
Constructor Details
#initialize(base_command) ⇒ Source
Returns a new instance of Source.
5 6 7 |
# File 'lib/plugin/commands/source.rb', line 5 def initialize(base_command) @base_command = base_command end |
Instance Method Details
#options ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/plugin/commands/source.rb', line 9 def OptionParser.new do |o| o.set_summary_indent(' ') o. = "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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/plugin/commands/source.rb', line 17 def parse!(args) .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 |