Class: Commands::Source
- Inherits:
-
Object
- Object
- Commands::Source
- Defined in:
- lib/commands/plugin/commands.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.
216 217 218 |
# File 'lib/commands/plugin/commands.rb', line 216 def initialize(base_command) @base_command = base_command end |
Instance Method Details
#options ⇒ Object
220 221 222 223 224 225 226 |
# File 'lib/commands/plugin/commands.rb', line 220 def OptionParser.new do |o| o.set_summary_indent(' ') o. = "Usage: #{@base_command.script_name} source REPOSITORY" o.define_head "Add a new repository." end end |
#parse!(args) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/commands/plugin/commands.rb', line 228 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 |