2019-10-13 22:42:15 +00:00
|
|
|
|
|
|
|
class Do < Process
|
|
|
|
class_property simulation = false
|
|
|
|
|
2019-10-30 15:02:57 +00:00
|
|
|
def self.run(cmd : String, params = [] of String)
|
2019-10-13 22:42:15 +00:00
|
|
|
if @@simulation
|
|
|
|
puts "simulation, do: #{cmd} #{params.join(" ")}"
|
|
|
|
Process::Status.new 0
|
|
|
|
else
|
|
|
|
Process.run cmd, params
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-30 15:02:57 +00:00
|
|
|
def self.run(cmd : String, params = [] of String, &block : Process -> _)
|
2019-10-13 22:42:15 +00:00
|
|
|
if @@simulation
|
|
|
|
puts "simulation, do: #{cmd} #{params.join(" ")}"
|
|
|
|
Process::Status.new 0
|
|
|
|
else
|
|
|
|
Process.run cmd, params, &block
|
|
|
|
end
|
|
|
|
end
|
2019-11-16 19:12:58 +00:00
|
|
|
|
|
|
|
def self.runsh(cmd : String)
|
|
|
|
if @@simulation
|
|
|
|
puts "simulation, do in a shell : #{cmd}"
|
|
|
|
Process::Status.new 0
|
|
|
|
else
|
|
|
|
r = Process.run "sh", ["-c", cmd],
|
|
|
|
output: Process::Redirect::Inherit,
|
|
|
|
error: Process::Redirect::Inherit
|
|
|
|
end
|
|
|
|
end
|
2019-10-13 22:42:15 +00:00
|
|
|
end
|