Sha256: d5e529e8982796271a28b2c91b8dbbb61821122d262b5d5c899123d6925324f5

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

require 'logger'

require 'gerrit/cli/errors'

module Gerrit
  module Cli
  end
end

class Gerrit::Cli::ShellRunner
  def initialize(logger)
    @logger = logger || Logger.new(STDOUT)
  end

  def system!(command)
    @logger.debug("+ #{command}")

    unless system(command)
      st = $?.exitstatus
      emsg = "Command '#{command}' exited with non-zero status (#{st})."
      raise Gerrit::Cli::Error.new(emsg)
    end
  end

  def capture!(command)
    @logger.debug("+ #{command}")

    out = `#{command}`
    unless $?.success?
      st = $?.exitstatus
      emsg = "Command '#{command}' exited with non-zero status (#{st})."
      raise Gerrit::Cli::Error.new(emsg)
    end

    out
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gerrit-cli-0.0.1 lib/gerrit/cli/shell_runner.rb