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)