Method: Cloudit::Command.run

Defined in:
lib/cloudit/command.rb

.run(command, args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cloudit/command.rb', line 23

def self.run(command, args)
  begin
    if command.nil?
      command = 'index'
    elsif command == 'index'
      raise NameError if command == 'index'
    end
    klass = "Cloudit::Command::#{command.capitalize}"
    instance = Object.const_get(klass).new(args)
  rescue NameError
    $stdout.puts "cloudit: '#{command}' is not a cloudit command.\nSee 'cloudit --help' for usage."
    exit(1)
  end
  instance.execute
end