santifer/career-ops · error

unknown option

Error message

unknown option: ${arg}

What it means

CLI argument validation in verify-cv-facts.mjs's parseCliArgs: a token starting with "--" matched none of the recognized options (--source, --config, --help/-h, --json). The interpolated value is the unrecognized flag itself; the input at fault is that command-line argument.

Solutions

  1. Run node verify-cv-facts.mjs --help to list the supported flags
  2. Fix the flag spelling — e.g. --sources is not valid, use --source (repeatable)
  3. Remove flags that this script does not support

Example fix

// before
$ node verify-cv-facts.mjs cv.md --sources a.md
// after
$ node verify-cv-facts.mjs cv.md --source a.md
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = new Set(['--source','--config','--help','-h','--json']);
const unknown = args.filter(a => a.startsWith('--') && !KNOWN.has(a));
if (unknown.length) { console.error(`unknown option(s): ${unknown.join(' ')}`); process.exit(2); }

Try / catch

try {
  const parsed = parseCliArgs(process.argv.slice(2));
} catch (err) {
  if (err.message.startsWith('unknown option')) {
    console.error(`${err.message} — run with --help for valid flags`);
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing an unrecognized flag such as --sources (typo), --out, or a flag borrowed from another tool (e.g. --verbose) to verify-cv-facts.mjs.

Common situations: Typos and plural/singular mix-ups (--sources vs --source); assuming flags from a different validator script work here; copy-pasting a command line from another project's docs.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of santifer/career-ops@e7abd431fc (2026-09-16). Data as JSON: /api/errors/006c9edc3e4a69a5. Report an issue: GitHub.

Appendix: source

Thrown at verify-cv-facts.mjs:898

/** 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, tools, and delegated-work authorship) absent
from source files.
Default sources: cv.md, article-digest.md

View on GitHub (pinned to e7abd431fc)