Sha256: 149f138485b08727b44590ed443c6e6573fa0701d9e49ab67bc99976a5fa0944

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

require "open3"
require "rfix"
require "rfix/log"

module Rfix::Cmd
  include Rfix::Log

  def cmd(*args, quiet: false)
    out, err, status = Open3.capture3(*args)
    say_debug "[Cmd] {{command:#{args.join(' ')}}}"
    
    unless status.success?
      return yield if block_given?
      return if quiet

      say_error "[Cmd] {{italic:#{args.join(' ')}}}"
      say_error "[Pwd] {{italic:#{Dir.pwd}}}"
      say_error "[Err] {{error:#{err.strip}}}"

      exit status.exitstatus
    end

    out.lines.map(&:chomp)
  end

  def cmd_succeeded?(*cmd)
    Open3.capture2e(*cmd).last.success?
  end

  def params
    [
      "--word-diff-regex=[^[:space:]]",
      "--no-renames",
      "--no-merges",
      "--first-parent",
      "--diff-filter=AM",
      "-U0",
      "--no-color",
      "-p"
    ]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rfix-1.0.15.pre.116 lib/rfix/cmd.rb
rfix-1.0.15 lib/rfix/cmd.rb