Skip to main content
Version: v0.0.4

Function: parseCommand()

parseCommand(args, deps, posture?): Promise<RunResult>

Run the parse command.

Parameters

args

string[]

The arguments after the parse subcommand token.

deps

RunDeps

Injected input readers (RunDeps).

posture?

PhiPosture = VALUE_FREE

The resolved PhiPosture. Defaults to VALUE_FREE; under --unsafe-show-values a bounded excerpt of the offending input is appended to a CLI_PARSE_FAILED diagnostic (the single, opt-in value-echoing surface): single-record mode only.

Returns

Promise<RunResult>

A RunResult: the typed-JSON model (or NDJSON records) on stdout, a value-free note (or nothing) on stderr, and the resolved exit code. Never throws a CliError: it resolves it to a result; unexpected exceptions are caught by the dispatcher and mapped to CLI_INTERNAL.

Throws

Never CliError; may propagate a truly unexpected error for the dispatcher to map.

Example

import { parseCommand } from "@cosyte/cli";

const enc = new TextEncoder();
const deps = {
readFile: async () => enc.encode('{"resourceType":"Patient","id":"x"}'),
readStdin: async () => new Uint8Array(),
};
(await parseCommand(["patient.json"], deps)).exit; // => 0