variable InvalidFlag

A flag was given a value this parser will not accept.

Reported rather than exited on. Parsing argv is a pure transform, and the seven console.error + process.exit(1) pairs this replaces made it impossible to call from anywhere that must survive bad input: the daemon parses argv once per request and would have taken the whole daemon down with it, and the unit tests had to monkeypatch process.exit into throwing a Symbol to observe any of these branches at all.

cli.ts is now the single place that turns one of these into a message and an exit code.

import * as Args from './index.ts';

const failure = Args.InvalidFlag({ flag: '--port', value: 'abc', expected: 'Expected --port=<0-65535>.' });
failure.message; // 'Invalid --port value: "abc". Expected --port=<0-65535>.'
failure.data.flag; // '--port' — typed payload, no message parsing

Type

Failure.FailureFactory<
"InvalidFlag",
{ flag: string; value: string; expected: string; }
>

Usage

import { InvalidFlag } from "lib/args/parse.ts";