class RatatuiRuby::Tea::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.
Batch Mode (default)
A single message arrives when the command finishes: [tag, {stdout:, stderr:, status:}]
Streaming Mode
Messages arrive incrementally:
-
[tag, :stdout, line]for each stdout line -
[tag, :stderr, line]for each stderr line -
[tag, :complete, {status:}]when the command finishes -
[tag, :error, {message:}]if the command cannot start
The status is the integer exit code (0 = success).
Public Instance Methods
Source
# File lib/ratatui_ruby/tea/command.rb, line 211 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/ratatui_ruby/tea/command.rb, line 202 def stream? stream end
Returns true if streaming mode is enabled.