Skip to content

resolve

Generated reference page for the resolve function export.

Signatures

ts
function resolve(schema: CommandSchema, parsed: ParseResult, options?: ResolveOptions): Promise<ResolveResult>;
ParameterTypeDescription
schemaCommandSchemaThe command schema defining flags and args
parsedParseResultRaw parsed values from the parser
optionsResolveOptions | undefinedExternal state for the resolution chain

Members

Members

resolve

Resolve parsed values against a command schema.

Low-level API: most applications should rely on cli().run(), .execute(), or runCommand(), which already call resolve at the right time. Reach for this function when testing precedence rules directly or building custom execution flows around CommandSchema.

Resolution order:

  1. CLI parsed value (from ParseResult)
  2. Env variable (from ResolveOptions.env, if flag declares envVar)
  3. Config value (from ResolveOptions.config, if flag declares configPath)
  4. Prompt (from ResolveOptions.prompter, if flag declares prompt)
  5. Default value (from schema)

After resolution, validates that all required flags and args have a value. Collects all validation errors before throwing, so the user sees every missing field at once.

ts
(schema: CommandSchema, parsed: ParseResult, options?: ResolveOptions): Promise<ResolveResult>;

Examples

ts
const parsed = parse(deploy.schema, ['production']);
const resolved = await resolve(deploy.schema, parsed, {
  env: { DEPLOY_REGION: 'eu' },
});

See Also

Released under the MIT License.