Method: Toolshed::CLI#execute

Defined in:
lib/toolshed/cli.rb

#execute(command_name, args, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/toolshed/cli.rb', line 6

def execute(command_name, args, options={})
  Toolshed::Client.load_credentials_if_necessary
  command = commands[command_name]
  if command
    begin
      command.new.execute(args, options)
    rescue Toolshed::Error => e
      puts "An error occurred: #{e.message}"
    rescue RuntimeError => e
      puts "An error occurred: #{e.message}"
    end
  else
    raise CommandNotFound, "Unknown command: #{command_name}"
  end
end