class Omnibus::CLI::Runner
This is the main entry point for the CLI
. It exposes the method {#execute!} to start the CLI
.
@note the arity of {#initialize} and {#execute!} are extremely important for testing purposes. It is a requirement to perform in-process testing with Aruba. In process testing is much faster than spawning a new Ruby process for each test.
Public Class Methods
new(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
click to toggle source
# File lib/omnibus/cli.rb, line 33 def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel end
Public Instance Methods
execute!()
click to toggle source
# File lib/omnibus/cli.rb, line 37 def execute! $stdin = @stdin $stdout = @stdout $stderr = @stderr Omnibus::CLI.start(@argv) @kernel.exit(0) rescue Omnibus::Error => e error = Omnibus.ui.set_color(e.message, :red) backtrace = Omnibus.ui.set_color("\n" + e.backtrace.join("\n "), :red) Omnibus.ui.error(error) Omnibus.ui.error(backtrace) if e.respond_to?(:status_code) @kernel.exit(e.status_code) else @kernel.exit(1) end end