Sha256: f85b43d0116db3e974a35dcf4e0b293df4c025a21ba045b4cfb66e324e5ac6c8

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

require 'arli'
require 'arli/cli/app'

module Arli
  module CLI
    # For the reasons this file is the way it is, please refer to
    # https://github.com/erikhuda/thor/wiki/Integrating-with-Aruba-In-Process-Runs
    class Runner
      def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
        @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
      end

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

          Arli::CLI::App.new(@argv).start
          print_debug_info
          0
        rescue StandardError
          1
        rescue SystemExit => e
          e.status
        ensure
          $stderr = STDERR
          $stdin  = STDIN
          $stdout = STDOUT
        end
        @kernel.exit(exit_code)
      end

      def print_debug_info
        $stdout.puts JSON.pretty_generate(Arli.config.to_hash).gsub(/("\w+":)/, '\1'.bold.blue) \
          if Arli.config.debug
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
arli-1.4.0 lib/arli/cli/runner.rb
arli-1.3.0 lib/arli/cli/runner.rb
arli-1.2.1 lib/arli/cli/runner.rb
arli-1.1.0 lib/arli/cli/runner.rb
arli-1.0.2 lib/arli/cli/runner.rb
arli-1.0.1 lib/arli/cli/runner.rb