Standard Library
std.process
Process execution for running subprocesses and capturing their output.
Exported functions
Create run options with explicit env, cwd, stdin, and check settings.
Create default run options with no env/cwd/stdin overrides.
Create byte-oriented run options with explicit env, cwd, stdin, and check settings.
Create default byte-oriented run options with no env/cwd/stdin overrides.
Create spawn options with explicit env and cwd settings.
Create default spawn options with no env or cwd overrides.
Run a command synchronously and wait for it to complete.
Examples
const result = process.run("ls", ["-la"])
@println(result.stdout)
const result = process.run_with_options("npm", ["install"], {}, "/path/to/project", "")Run a command synchronously and capture stdout/stderr as raw bytes.
Run a command with Tea-native options.
Examples
use process from "std.process"
# Requires the Unix sort command.
const options = process.new_run_options_with({}, nil, "banana\napple\n", true)
const result = process.run_with("sort", [], options)
@println(process.stdout_lines(result)) # [apple, banana]Run a command with Tea-native byte-oriented options.
Run a command with full options (env, cwd, stdin).
Run a command with full byte-oriented options (env, cwd, stdin bytes).
Start a command without waiting for it to complete.
Examples
const handle = process.spawn("long-running-command", [])
# ... do other work ...
const result = process.wait(handle)Spawn a command with Tea-native options.
Spawn a command with full options (env, cwd).
Wait for a spawned process to complete and return its result.
Examples
const handle = process.spawn("command", [])
const result = process.wait(handle)
@println(result.exit)Terminate a spawned process.
Examples
const handle = process.spawn("command", [])
process.kill(handle)Read data from a spawned process's stdout.
Examples
const handle = process.spawn("command", [])
const output = process.read_stdout(handle)Read up to the specified number of bytes from a spawned process's stdout.
Read data from a spawned process's stderr.
Examples
const handle = process.spawn("command", [])
const errors = process.read_stderr(handle)Read up to the specified number of bytes from a spawned process's stderr.
Write data to a spawned process's stdin.
Examples
const handle = process.spawn("cat", [])
process.write_stdin(handle, "hello world")Write raw bytes to a spawned process's stdin.
Close a spawned process's stdin pipe.
Examples
const handle = process.spawn("sort", [])
process.write_stdin(handle, "banana\napple\ncherry")
process.close_stdin(handle)
const result = process.wait(handle)Close a spawned process handle without waiting for it.
Require a process result to have exited successfully.
Require a byte-oriented process result to have exited successfully.
Require a process result to have exited successfully with a typed error.
Run a command and fail when it exits with a non-zero status.
Run a command as bytes and fail when it exits with a non-zero status.
Run a command with Tea-native options and fail when it exits non-zero.
Run a command with Tea-native byte-oriented options and fail when it exits non-zero.
Run a command with full options and fail when it exits with a non-zero status.
Run a command with full byte-oriented options and fail on non-zero exit.
Run a command and return a typed error when it exits non-zero.
Examples
use process from "std.process"
def demonstrate() -> Void
# Requires a shell; this command deliberately exits with status 7.
try process.run_required("sh", ["-c", "exit 7"]) catch err
case is process.ProcessError.CommandFailed
@println(err.exit) # 7
return
case _
@panic("unexpected process error")
end
return
end
demonstrate()Run a command with Tea-native options and return a typed error on failure.
Split captured stdout into lines.
Split captured stderr into lines.