Method: Enom::CLI#execute

Defined in:
lib/enom/cli.rb

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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/enom/cli.rb', line 20

def execute(command_name, args, options={})
  command = commands[command_name]
  if command
    begin
      command.new.execute(args, options)
    rescue Enom::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