Method: Skytap#exec!

Defined in:
lib/skytap.rb

#exec!Object

Returns a numeric code indicating exit status; 0 iff success.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/skytap.rb', line 47

def exec! #TODO:NLA Rename to something indicating that this is called when running from a command-line context.
  response = begin
    args, global_options, command_options = CommandLine.parse(ARGV)

    logger = Logger.new(global_options[:'log-level'])

    # Disable color if needed. We don't unconditionally execute this line so that
    # color is still disabled for non-TTY terminals irrespective of the colorize
    # setting.
    Sickill::Rainbow.enabled = false unless global_options[:colorize]

    build_response(Commands::Root.go!(logger, args, global_options, command_options))
  rescue SystemExit
    raise
  rescue Interrupt
    return 0
  rescue Exception => ex
    log_exception(ex, args, global_options, command_options)
    build_response(ex)
  end

  if response.error?
    if logger
      logger.info response.error_message
    else
      $stderr.puts response.error_message
    end
    return 1
  else
    return 0
  end
end