runCommand
Generated reference page for the runCommand function export.
- Import:
@kjanat/dreamcli/testkit - Export kind: function
- Declared in:
src/core/testkit/index.ts - Source link:
src/core/testkit/index.ts:53
Signatures
ts
function runCommand(cmd: RunnableCommand, argv: readonly string[], options?: RunOptions): Promise<RunResult>;| Parameter | Type | Description |
|---|---|---|
cmd | RunnableCommand | The command builder (must have an action handler) |
argv | readonly string[] | Raw argv strings (NOT including the command name itself). CLI-level --json and --quiet/-q before the -- separator are honoredand stripped here, just like the real CLI root — so ['--json'] enablesJSON mode and ['--quiet'] sets quiet verbosity rather than failing asunknown flags. Equivalent to { jsonMode: true } / { verbosity: 'quiet' }. |
options | RunOptions | undefined | Injectable 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:
- Apply the CLI root-flag layer (detect/strip
--jsonand--quiet/-q) so copied real argv works - Create or reuse capture output
- Build standalone schema/meta defaults when CLI dispatch did not
- Delegate parse -> resolve -> execute to the shared executor
- 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?: RunOptions): Promise<RunResult>;Related Examples
- Testing examples using @kjanat/dreamcli/testkit. -
examples/testing.ts