child_process

Package Version Hex Docs

A cross-platform library for spawning child processes in Gleam, inspired by Rust’s std::process module.

Run shell commands, execute binaries with full control over stdio, or even launch interactive programs like vim directly from your Gleam code.

gleam add child_process@1

Features

Usage

Run a shell command

import child_process

let assert Ok(output) = child_process.shell("echo Hello, World!")
io.println(output)

Launch interactive programs

import child_process
import child_process/stdio

// Run vim interactively - stdio is inherited so you can use it normally!
child_process.new("vim")
|> child_process.arg("README.md")
|> child_process.stdio(stdio.inherit())
|> child_process.run()

Stream output line-by-line

import child_process
import child_process/stdio

// Watch mode with live output
child_process.new("tailwindcss")
|> child_process.args(["-i", "input.css", "-o", "output.css", "--watch"])
|> child_process.stdio(stdio.lines(fn(line) {
  io.println(line)
}))
|> child_process.spawn()

Further documentation can be found at https://hexdocs.pm/child_process.

Search Document