class RSGuitarTech::CommandRunner

Attributes

cmd[RW]

Public Class Methods

new(args, skip_escaping: false) click to toggle source
# File lib/rsgt/command_runner.rb, line 13
def initialize(args, skip_escaping: false)
  if skip_escaping
    @cmd = Array(args).join " "
  else
    @cmd = Shellwords.join Array(args)
  end
end
run!(args, skip_escaping: false) click to toggle source
# File lib/rsgt/command_runner.rb, line 7
def self.run!(args, skip_escaping: false)
  self.new(args, skip_escaping: skip_escaping).run!
end

Public Instance Methods

run!() click to toggle source
# File lib/rsgt/command_runner.rb, line 21
def run!
  if RSGuitarTech.verbose
    puts "*" * 40
    puts ""
    puts cmd
    puts ""
  end

  stdout, stderr, status = Open3.capture3(cmd)
  if RSGuitarTech.verbose
    stdout.split("\n").each do |line|
      puts "--- #{line}"
    end
    stderr.split("\n").each do |line|
      puts "!!! #{line}"
    end
  end
  status
end