Skip to content

runCommand

Generated reference page for the runCommand function export.

Signatures

ts
function runCommand(cmd: RunnableCommand, argv: readonly string[], options?: RunCommandOptions): Promise<RunResult>;
ParameterTypeDescription
cmdRunnableCommandThe command builder (must have an action handler)
argvreadonly string[]Raw argv strings (NOT including the command name itself).
CLI-level --json and --quiet/-q before the -- separator are honored
and stripped here, just like the real CLI root — so ['--json'] enables
JSON mode and ['--quiet'] sets quiet verbosity rather than failing as
unknown flags. Equivalent to { jsonMode: true } / { verbosity: 'quiet' }.
Both accept an explicit value (--json=false), and an invalid one fails
with the same INVALID_VALUE error the CLI root produces. Pass
options.builtins to mirror a CLI that released one of these tokens to its
commands.
optionsRunCommandOptions | undefinedInjectable runtime state

Members

Members

runCommand

Run a command builder against the given argv with injected options.

This is the testkit wrapper around the shared executor:

  1. Apply the CLI root-flag layer (detect/strip --json and --quiet/-q) so copied real argv works
  2. Create or reuse capture output
  3. Build standalone schema/meta defaults when CLI dispatch did not
  4. Delegate parse -> resolve -> execute to the shared executor
  5. Return the structured result with captured buffers

Errors are normalized by the shared executor into structured RunResults with appropriate exit codes. The function never throws.

ts
(cmd: RunnableCommand, argv: readonly string[], options?: RunCommandOptions): Promise<RunResult>;

See Also

Released under the MIT License.