santifer/career-ops · error · Error

unknown option: ${arg}

Error message

unknown option: ${arg}

What it means

verify-cv-facts.mjs's parseCliArgs() accepts exactly --source, --config, --json, --help/-h plus one positional target; any other token starting with '--' is rejected as unknown. This is strict-fail-fast CLI parsing so typos (e.g. --sources, --json-output) do not silently change behavior.

Source

Thrown at verify-cv-facts.mjs:438

/** Parse the fact-validator command-line arguments. */
function parseCliArgs(args) {
  const sourcePaths = [];
  let targetArg = '';
  let configPath = DEFAULT_CONFIG;
  let json = false;
  for (let i = 0; i < args.length; i++) {
    const arg = args[i];
    if (arg === '--source' || arg === '--config') {
      if (!args[i + 1]) throw new Error(`${arg} requires a path`);
      if (arg === '--source') sourcePaths.push(args[++i]);
      else configPath = args[++i];
    } else if (arg === '--help' || arg === '-h') {
      return { help: true };
    } else if (arg === '--json') {
      json = true;
    } else if (arg.startsWith('--')) {
      throw new Error(`unknown option: ${arg}`);
    } else if (!targetArg) {
      targetArg = arg;
    } else {
      throw new Error(`unexpected extra positional argument: ${arg}`);
    }
  }
  return { targetArg, sourcePaths, configPath, json, help: false };
}

/** Return the command-line usage text. */
function usage() {
  return `Usage: node verify-cv-facts.mjs <generated-document> [--source path] [--config path] [--json]
       node verify-cv-facts.mjs --self-test

Checks generated candidate-facing text for unsupported metrics and explicitly asserted
non-metric facts (employers, titles, and tools) absent from source files.
Default sources: cv.md, article-digest.md
Default config:  config/cv-facts.json (optional)`;

View on GitHub (pinned to 60398d6549)

Solutions

  1. Run `node verify-cv-facts.mjs --help` and use only the documented flags: --source, --config, --json, --help
  2. Fix the typo (most often --sources -> --source)
  3. For a target file whose name starts with '--', reference it via an absolute path or rename it

Example fix

# before
node verify-cv-facts.mjs --sources cv.md output/cover.md
# after
node verify-cv-facts.mjs --source cv.md output/cover.md
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['--source', '--config', '--json', '--help', '-h']);
for (const a of process.argv.slice(2)) {
  if (a.startsWith('--') && !ALLOWED.has(a) && !ALLOWED.has(a.split('=')[0])) {
    console.error(`unknown option: ${a} — run --help`);
    process.exit(2);
  }
}

Try / catch

try {
  const { targetArg } = parseCliArgs(args);
} catch (err) {
  if (/^unknown option:/.test(err.message)) {
    console.error(err.message);
    console.error(usage());
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: Typing `--sources cv.md`, `--JSON`, `--verbose`, or `--output=x`. Even a correctly-placed path prefixed with '--' (e.g. a filename literally starting with dashes) hits this branch.

Common situations: Pluralizing flags from memory; flags copied from a different career-ops script's usage; boolean-flag assumptions (there is no --no-json); filenames that begin with '--'.

Related errors


AI-assisted analysis of santifer/career-ops@60398d6549 (2026-08-20). Data as JSON: /api/errors/006c9edc3e4a69a5. Report an issue: GitHub.