Module: Chimps::CLI

Includes:
Commands
Defined in:
lib/chimps-cli.rb

Overview

Defines methods for choosing which Chimps::Command class should be instantiated from the ARGV passed in on the command line.

Class Method Summary collapse

Methods included from Commands

class_for, included

Class Method Details

.execute!Object

Execute the Chimps command specified on the command line.

Will exit the Ruby process with 0 on success or 1 on an error.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chimps-cli.rb', line 21

def self.execute!
  begin
    Chimps.boot!
    if command
      Chimps.config.command_settings.resolve!
      command.execute!
      return 0
    else
      $stderr.puts Chimps.config.usage
      Chimps.config.dump_help
      return 1
    end
  rescue Chimps::Error, Configliere::Error => e
    $stderr.puts e.message
    return 1
  rescue => e
    $stderr.puts("#{e.message} (#{e.class})")
    $stderr.puts(e.backtrace.join("\n"))
    return 2
  end
end