Class: DreamOps::Cli::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/dream-ops/cli.rb

Overview

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.

This is the main entry point for the CLI. It exposes the method #execute! to start the CLI.

Instance Method Summary collapse

Constructor Details

#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ Runner

Returns a new instance of Runner.



17
18
19
# File 'lib/dream-ops/cli.rb', line 17

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



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dream-ops/cli.rb', line 21

def execute!
  $stdin  = @stdin
  $stdout = @stdout
  $stderr = @stderr

  DreamOps::Cli.start(@argv)
  @kernel.exit(0)
rescue DreamOps::DreamOpsError => e
  DreamOps.ui.error e
  DreamOps.ui.error "\t" + e.backtrace.join("\n\t") if ENV["DREAMOPS_DEBUG"]
  @kernel.exit(e.status_code)
end