Module

pooka/process

src/pooka/process.pooka

An external command is a visitor, with its own voice and exit status.

Run executables with an explicit argument list and capture stdout and stderr separately. A nonzero exit is an Output value, not a launch error. Child stdin starts at EOF; timeout results use None when the deadline wins. The current runner targets POSIX hosts.

Pooka
import pooka/process

let assert Ok(output) = process.run("printf", ["%s", "hello"])
assert output.stdout == "hello"

API reference

class

ProcessError

src/pooka/process.pooka:21
class ProcessError(message: String)

A process failure carrying the details needed by its caller. Keep this value in Result until a boundary can explain it.

field

message

src/pooka/process.pooka:21
message: String
INFERREDString
constructor

new

src/pooka/process.pooka:21
INFERREDfn(String) -> pooka/process.ProcessError
class

Output

src/pooka/process.pooka:25
class Output(status: Int, stdout: String, stderr: String)

A completed command report: exit status, captured stdout and captured stderr. Nonzero status is still a completed command.

field

status

src/pooka/process.pooka:25
status: Int
INFERREDInt
field

stdout

src/pooka/process.pooka:25
stdout: String
INFERREDString
field

stderr

src/pooka/process.pooka:25
stderr: String
INFERREDString
constructor

new

src/pooka/process.pooka:25
INFERREDfn(Int, String, String) -> pooka/process.Output
method

succeeded

src/pooka/process.pooka:33
succeeded() -> Bool
INFERREDfn() -> Bool

Check whether the command's exit status was zero.

Pooka
import pooka/process

assert process.Output(0, "", "").succeeded()
function

exit

src/pooka/process.pooka:70
exit(code: Int) -> Nil
INFERREDfn(Int) -> Nil

End the running application VM with the given exit status. This call does not return normally.

Pooka
import pooka/process

process.exit(0)
function

run

src/pooka/process.pooka:93
run(command: String, args: List(String)) -> Result(Output, ProcessError)
INFERREDfn(String, List(String)) -> Result(pooka/process.Output, pooka/process.ProcessError)

Run an executable with literal arguments and collect both output streams. A nonzero status remains an Output.

Pooka
import pooka/process

let assert Ok(output) = process.run("printf", ["%s", "oak"])
function

run_in

src/pooka/process.pooka:104
run_in(
  command: String,
  args: List(String),
  directory: String
) -> Result(Output, ProcessError)
INFERREDfn(String, List(String), String) -> Result(pooka/process.Output, pooka/process.ProcessError)

Run a command with an explicit working directory.

Pooka
import pooka/process

let result = process.run_in("pwd", [], ".")
function

run_with_timeout

src/pooka/process.pooka:120
run_with_timeout(
  command: String,
  args: List(String),
  milliseconds: Int
) -> Result(Option(Output), ProcessError)
INFERREDfn(String, List(String), Int) -> Result(Option(pooka/process.Output), pooka/process.ProcessError)

Return Some(Output) if the command finishes, None if the deadline wins, or ProcessError for launch failure.

Pooka
import pooka/process

let result = process.run_with_timeout("printf", ["oak"], 1000)
function

pid

src/pooka/process.pooka:139
pid() -> Int
INFERREDfn() -> Int

Read the process identifier supplied by the runtime bridge.

Pooka
import pooka/process

let identifier = process.pid()