Method: Consoler::Application#run

Defined in:
lib/consoler/application.rb

#run(args = ARGV, disable_usage_message = false) ⇒ mixed

Run the application with a list of arguments

Parameters:

  • (defaults to: ARGV)

    Arguments

  • (defaults to: false)

    Disable the usage message when nothing it matched

Returns:

  • Result of your matched command, nil otherwise



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/consoler/application.rb', line 91

def run(args = ARGV, disable_usage_message = false)
  # TODO: signal handling of some kind?

  result, matched = _run(args.dup)

  if !matched && !disable_usage_message
    usage
  end

  result
rescue RuntimeError => e
  if @rescue_errors
    $stderr.puts "A runtime error occured: #{e.message.strip}"
    nil
  else
    raise e
  end
end