1
0
mirror of https://git.baguette.netlib.re/Baguette/networkctl synced 2024-12-18 13:03:30 +00:00
networkctl/src/do.cr
2019-11-16 20:12:58 +01:00

34 lines
734 B
Crystal

class Do < Process
class_property simulation = false
def self.run(cmd : String, params = [] of String)
if @@simulation
puts "simulation, do: #{cmd} #{params.join(" ")}"
Process::Status.new 0
else
Process.run cmd, params
end
end
def self.run(cmd : String, params = [] of String, &block : Process -> _)
if @@simulation
puts "simulation, do: #{cmd} #{params.join(" ")}"
Process::Status.new 0
else
Process.run cmd, params, &block
end
end
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
end