Module: Modsvaskr::RunCmd

Included in:
Game, TestsSuite, Ui, Xedit
Defined in:
lib/modsvaskr/run_cmd.rb

Instance Method Summary collapse

Instance Method Details

#run_cmd(cmd, args: []) ⇒ Object

Run a given command with eventual parameters

Parameters
  • cmd (Hash<Symbol,Object>): The command description:

    • dir (String): Directory in which the command is found

    • exe (String): Name of the executable of the command

    • args (Array<String>): Default arguments of the command [default = []]

  • args (Array<String>): Additional arguments to give the command [default: []]



13
14
15
16
17
18
# File 'lib/modsvaskr/run_cmd.rb', line 13

def run_cmd(cmd, args: [])
  Dir.chdir cmd[:dir] do
    cmd_line = "#{cmd[:exe]} #{((cmd.key?(:args) ? cmd[:args] : []) + args).join(' ')}"
    raise "Unable to execute command line from \"#{dir}\": #{cmd_line}" unless system cmd_line
  end
end