CodexWrapper.Command behaviour (CodexWrapper v0.4.0)

Copy Markdown View Source

Behaviour for CLI commands.

Every command knows how to build its argument list and how to parse its output. Synchronous execution routes through the configured CodexWrapper.Runner; the default runner closes stdin (Codex CLI hangs if stdin is inherited from the parent).

Summary

Functions

Run a command synchronously through the configured CodexWrapper.Runner.

Types

args()

@type args() :: [String.t()]

Callbacks

args(command)

@callback args(command :: struct()) :: args()

parse_output(stdout, exit_code)

@callback parse_output(stdout :: String.t(), exit_code :: non_neg_integer()) ::
  {:ok, term()} | {:error, term()}

Functions

run(mod, command, config)

@spec run(module(), struct(), CodexWrapper.Config.t()) ::
  {:ok, term()} | {:error, term()}

Run a command synchronously through the configured CodexWrapper.Runner.

Returns the parsed output on success. On timeout the default runner abandons the OS process group; CodexWrapper.Runner.Forcola kills it.