Method: App42::Command::Client#start

Defined in:
lib/app42/command/client.rb

#start(command, args = []) ⇒ Object

Parameters:

  • command (Object)
  • args (Object) (defaults to: [])


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/app42/command/client.rb', line 93

def start(command, args = [])
  if is_available?(command)
    parse_options(command.downcase, args)
    execute command.downcase
    cmd = App42::Command.const_get(@kclass.to_s.capitalize)
    begin
      cmd.new(@options).send(@command)
    rescue Interrupt
      puts Paint[" Command cancelled.", :red]
      exit!
    rescue Exception => e
      puts e
    end
  elsif command == 'help'
    send(command.downcase)
  else
    puts Paint["app42: Unknown command [#{command}]", :red]
    App42::Base::Help.how_to
  end
end