Class: Omnibus::CLI::Runner
- Inherits:
-
Object
- Object
- Omnibus::CLI::Runner
- Includes:
- Logging
- Defined in:
- lib/omnibus/cli.rb
Overview
Note:
the arity of #initialize and #execute! are extremely important
This is the main entry point for the CLI. It exposes the method #execute! to start the CLI.
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.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Runner
constructor
A new instance of Runner.
Methods included from Logging
Constructor Details
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Runner
Returns a new instance of Runner.
33 34 35 |
# 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 |
Instance Method Details
#execute! ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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., :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 |