Bsdkrun.Cli (bsdkrun_ex v0.1.0)

Copy Markdown View Source

Shells out to the bsdkrun binary via System.cmd/3.

Every invocation is prefixed with the global --log-level flag (default 0) so the SDK's captured output stays clean. Because System.cmd/3 cannot split stderr from stdout — nor feed stdin — the child is wrapped in a tiny /bin/sh -c that redirects 2> (and optionally 0<) to temp files, which we read back and delete. The result is a map of stdout, stderr, exit_code.

Summary

Types

Options accepted by run/2.

Functions

Run bsdkrun <args> and return {:ok, result} on exit 0, or {:error, %Bsdkrun.Error{}} (kind :command_failed) otherwise. label names the command for error messages.

Run bsdkrun <args> to completion, buffering stdout/stderr separately.

Types

result()

@type result() :: %{stdout: String.t(), stderr: String.t(), exit_code: integer()}

run_opt()

@type run_opt() ::
  {:log_level, non_neg_integer()}
  | {:env, map() | keyword()}
  | {:stdin, iodata()}

Options accepted by run/2.

Functions

checked(args, label, opts \\ [])

@spec checked([String.t()], String.t(), [run_opt()]) ::
  {:ok, result()} | {:error, Bsdkrun.Error.t()}

Run bsdkrun <args> and return {:ok, result} on exit 0, or {:error, %Bsdkrun.Error{}} (kind :command_failed) otherwise. label names the command for error messages.

run(args, opts \\ [])

@spec run([String.t()], [run_opt()]) :: result()

Run bsdkrun <args> to completion, buffering stdout/stderr separately.

Options:

  • :log_level — the global --log-level (default 0).
  • :env — extra environment variables merged onto the process env.
  • :stdin — data piped to the child's stdin.