Tea — a strongly typed scripting language
Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

Agent documentationContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.encodingstd.envstd.fsstd.hashstd.httpstd.netstd.jsonstd.mathstd.parsestd.pathstd.processstd.randomstd.raylibstd.regexstd.stringstd.timestd.url

Read as Markdown

Standard Library

std.process

Process execution for running subprocesses and capturing their output.

Exported functions

pub def new_run_options_with(env: Dict[String, String], cwd: String?, stdin: String?, check_enabled: Bool) -> RunOptions

Create run options with explicit env, cwd, stdin, and check settings.

pub def new_run_options() -> RunOptions

Create default run options with no env/cwd/stdin overrides.

pub def new_run_bytes_options_with(env: Dict[String, String], cwd: String?, stdin: List[Int]?, check_enabled: Bool) -> RunBytesOptions

Create byte-oriented run options with explicit env, cwd, stdin, and check settings.

pub def new_run_bytes_options() -> RunBytesOptions

Create default byte-oriented run options with no env/cwd/stdin overrides.

pub def new_spawn_options_with(env: Dict[String, String], cwd: String?) -> SpawnOptions

Create spawn options with explicit env and cwd settings.

pub def new_spawn_options() -> SpawnOptions

Create default spawn options with no env or cwd overrides.

pub def run(command: String, args: List[String]) -> ProcessResult ! ProcessError

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", "")
pub def run_bytes(command: String, args: List[String]) -> ProcessBytesResult ! ProcessError

Run a command synchronously and capture stdout/stderr as raw bytes.

pub def run_with(command: String, args: List[String], options: RunOptions) -> ProcessResult ! ProcessError

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]
pub def run_bytes_with(command: String, args: List[String], options: RunBytesOptions) -> ProcessBytesResult ! ProcessError

Run a command with Tea-native byte-oriented options.

pub def run_with_options(command: String, args: List[String], env: Dict[String, String], cwd: String, stdin: String) -> ProcessResult ! ProcessError

Run a command with full options (env, cwd, stdin).

pub def run_bytes_with_options(command: String, args: List[String], env: Dict[String, String], cwd: String, stdin: List[Int]) -> ProcessBytesResult ! ProcessError

Run a command with full byte-oriented options (env, cwd, stdin bytes).

pub def spawn(command: String, args: List[String]) -> Int ! ProcessError

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)
pub def spawn_with(command: String, args: List[String], options: SpawnOptions) -> Int ! ProcessError

Spawn a command with Tea-native options.

pub def spawn_with_options(command: String, args: List[String], env: Dict[String, String], cwd: String) -> Int ! ProcessError

Spawn a command with full options (env, cwd).

pub def wait(handle: Int) -> ProcessResult ! ProcessError

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)
pub def kill(handle: Int) -> Bool ! ProcessError

Terminate a spawned process.

Examples

const handle = process.spawn("command", [])
process.kill(handle)
pub def read_stdout(handle: Int) -> String ! ProcessError

Read data from a spawned process's stdout.

Examples

const handle = process.spawn("command", [])
const output = process.read_stdout(handle)
pub def read_stdout_bytes(handle: Int, bytes: Int) -> List[Int] ! ProcessError

Read up to the specified number of bytes from a spawned process's stdout.

pub def read_stderr(handle: Int) -> String ! ProcessError

Read data from a spawned process's stderr.

Examples

const handle = process.spawn("command", [])
const errors = process.read_stderr(handle)
pub def read_stderr_bytes(handle: Int, bytes: Int) -> List[Int] ! ProcessError

Read up to the specified number of bytes from a spawned process's stderr.

pub def write_stdin(handle: Int, data: String) -> Void ! ProcessError

Write data to a spawned process's stdin.

Examples

const handle = process.spawn("cat", [])
process.write_stdin(handle, "hello world")
pub def write_stdin_bytes(handle: Int, data: List[Int]) -> Void ! ProcessError

Write raw bytes to a spawned process's stdin.

pub def close_stdin(handle: Int) -> Void ! ProcessError

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)
pub def close(handle: Int) -> Void ! ProcessError

Close a spawned process handle without waiting for it.

pub def check(result: ProcessResult) -> ProcessResult ! ProcessError

Require a process result to have exited successfully.

pub def check_bytes(result: ProcessBytesResult) -> ProcessBytesResult ! ProcessError

Require a byte-oriented process result to have exited successfully.

pub def require(result: ProcessResult) -> ProcessResult ! ProcessError.CommandFailed

Require a process result to have exited successfully with a typed error.

pub def run_checked(command: String, args: List[String]) -> ProcessResult ! ProcessError

Run a command and fail when it exits with a non-zero status.

pub def run_bytes_checked(command: String, args: List[String]) -> ProcessBytesResult ! ProcessError

Run a command as bytes and fail when it exits with a non-zero status.

pub def run_checked_with(command: String, args: List[String], options: RunOptions) -> ProcessResult ! ProcessError

Run a command with Tea-native options and fail when it exits non-zero.

pub def run_bytes_checked_with(command: String, args: List[String], options: RunBytesOptions) -> ProcessBytesResult ! ProcessError

Run a command with Tea-native byte-oriented options and fail when it exits non-zero.

pub def run_checked_with_options(command: String, args: List[String], env: Dict[String, String], cwd: String, stdin: String) -> ProcessResult ! ProcessError

Run a command with full options and fail when it exits with a non-zero status.

pub def run_bytes_checked_with_options(command: String, args: List[String], env: Dict[String, String], cwd: String, stdin: List[Int]) -> ProcessBytesResult ! ProcessError

Run a command with full byte-oriented options and fail on non-zero exit.

pub def run_required(command: String, args: List[String]) -> ProcessResult ! ProcessError

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()
pub def run_required_with(command: String, args: List[String], options: RunOptions) -> ProcessResult ! ProcessError

Run a command with Tea-native options and return a typed error on failure.

pub def stdout_lines(result: ProcessResult) -> List[String]

Split captured stdout into lines.

pub def stderr_lines(result: ProcessResult) -> List[String]

Split captured stderr into lines.