To run commands, create an instance of Run::Command or Run::CommandGroup and call its #run method.
Run::Command is for running a single command.
Run::Command.new("echo", [":)"]).run # => prints ":)"
Run::CommandGroup is for running multiple commands.
cg = Run::CommandGroup.new [":)", ":P", ":X"].each do |face| cg.command "echo", [face] end cg.run # prints these faces
Child commands in a command group are run sequentially as default. To run them in parallel, use the parallel context attribute.
cg = Run::CommandGroup.new cg.command "sleep", ["100"] cg.command "echo", ["leave you, sleepy"] cg.run parallel: true
Note: The parallel attribute is not inherited from the parent context.
cg = Run::CommandGroup.new(parallel: true) do |g| g.group do cmd "sleep", %w(1) cmd "sleep", %w(1) cmd "sleep", %w(1) end end cg.run.wait
This waits for 3 seconds not 1.
There was an error while loading. Please reload this page.