Skip to content

ResolutionProvenance ​

Which stage produced a resolved value, and how.

via and trigger distinguish the two ways stdin delivers bytes. An explicit - keeps CLI precedence and reports { stage: 'cli', via: 'stdin', trigger: 'dash' }; an absent input takes the fallback stage between CLI and env and reports { stage: 'stdin', via: 'stdin', trigger: 'fallback' }.

The 'env' stage is two records the same way. A variable bound by name reports { stage: 'env', envVar }, the one concrete variable that supplied the value. An indexed family bound with an IndexedEnvBinding reports { stage: 'env', via: 'indexed', count, envVars }: the count variable that claimed the input and every member variable read, in entry order and, within an entry, in field order. envVars is empty when the count is 0. Test 'envVar' in source (or source.via) before reading either shape's fields.

Signatures ​

ts
type ResolutionProvenance = { stage: "cli"; } | { stage: "cli"; via: "stdin"; trigger: "dash"; } | { stage: "stdin"; via: "stdin"; trigger: "fallback"; } | { stage: "env"; envVar: string; } | { stage: "env"; via: "indexed"; count: string; envVars: readonly string[]; } | { stage: "config"; configPath: string; } | { stage: "prompt"; } | { stage: "default"; };

Examples ​

ts
command('deploy')
  .flag('region', flag.string().env('REGION').default('us'))
  .action(({ sources }) => {
    const region = sources.flags.region;
    if (region?.stage === 'env' && 'envVar' in region) console.log(`from ${region.envVar}`);
  });

See Also ​

Released under the MIT License.