bsdkrun/cli

Shelling out to the bsdkrun binary.

Every invocation is prefixed with the global --log-level flag (default 0) so the SDK’s captured output stays clean. stdout and stderr are buffered separately.

Types

How to run a command. Build one with options and adjust with the with_* helpers.

pub type Options {
  Options(
    log_level: Int,
    env: List(#(String, String)),
    stdin: option.Option(String),
  )
}

Constructors

  • Options(
      log_level: Int,
      env: List(#(String, String)),
      stdin: option.Option(String),
    )

A completed bsdkrun invocation.

pub type Output {
  Output(stdout: String, stderr: String, exit_code: Int)
}

Constructors

  • Output(stdout: String, stderr: String, exit_code: Int)

Values

pub fn checked(
  args: List(String),
  label: String,
  opts: Options,
) -> Result(Output, error.Error)

Run bsdkrun <args> and fail on a non-zero exit. label names the command in the resulting error.

pub fn checked_unit(
  args: List(String),
  label: String,
  opts: Options,
) -> Result(Nil, error.Error)

Like checked, but discards the output — for commands run only for their effect (stop, rm, update, …).

pub fn options() -> Options

Default run options: log level 0, no extra environment, no stdin.

pub fn run(
  args: List(String),
  opts: Options,
) -> Result(Output, error.Error)

Run bsdkrun <args> to completion and return its captured output, whatever the exit code. Only binary resolution can fail here.

pub fn run_inherit(
  args: List(String),
) -> Result(Int, error.Error)

Run bsdkrun <args> with the child wired to this node’s own stdio, for interactive subcommands. Blocks until it exits and returns its exit code.

pub fn with_env(
  opts: Options,
  env: List(#(String, String)),
) -> Options

Merge extra environment variables onto the child’s environment.

pub fn with_log_level(opts: Options, level: Int) -> Options

Set the global --log-level for this invocation.

pub fn with_stdin(opts: Options, data: String) -> Options

Pipe data to the child’s stdin.

Search Document