class Rooibos::Command::System
Runs a shell command and routes its output back as messages.
Apps run external tools: linters, compilers, scripts, system utilities. The runtime dispatches the command in a thread, so the UI stays responsive. Batch mode (default) waits for completion; streaming mode shows output live. Orphaned child processes linger and waste resources, so cancellation sends SIGTERM for graceful shutdown, then SIGKILL to prevent orphans.
Use it to run builds, lint files, execute scripts, or invoke any CLI tool.
Prefer the Command.system factory method for convenience.
Batch Mode (default)
A single message arrives when the command finishes: Message::System::Batch with stdout, stderr, status.
Streaming Mode
Message::System::Stream messages arrive incrementally:
stream: :stdout-
for each stdout chunk
stream: :stderr-
for each stderr chunk
stream: :complete-
when the command finishes
stream: :error-
if the command cannot start
Example
# Using the factory method (recommended) Command.system("ls -la", :got_files) Command.system("tail -f log.txt", :log, stream: true) # Using the class directly System.new(command: "ls -la", envelope: :got_files, stream: false)
Public Instance Methods
Source
# File lib/rooibos/command.rb, line 293 def call(out, token) require "open3" if stream? stream_execution(out, token) else batch_execution(out) end end
Executes the shell command and sends results via outlet.
In batch mode, sends a single message with all output. In streaming mode, sends incremental messages as output arrives. Respects cancellation token by sending SIGTERM (then SIGKILL) to child.
Source
# File lib/rooibos/command.rb, line 284 def stream? stream end
Returns true if streaming mode is enabled.