{"record":{"id":"006c9edc3e4a69a5","repo":"santifer/career-ops","slug":"unknown-option-arg-006c9e","errorCode":null,"errorMessage":"unknown option: ${arg}","messagePattern":"unknown option: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"verify-cv-facts.mjs","lineNumber":438,"sourceCode":"\n/** Parse the fact-validator command-line arguments. */\nfunction parseCliArgs(args) {\n  const sourcePaths = [];\n  let targetArg = '';\n  let configPath = DEFAULT_CONFIG;\n  let json = false;\n  for (let i = 0; i < args.length; i++) {\n    const arg = args[i];\n    if (arg === '--source' || arg === '--config') {\n      if (!args[i + 1]) throw new Error(`${arg} requires a path`);\n      if (arg === '--source') sourcePaths.push(args[++i]);\n      else configPath = args[++i];\n    } else if (arg === '--help' || arg === '-h') {\n      return { help: true };\n    } else if (arg === '--json') {\n      json = true;\n    } else if (arg.startsWith('--')) {\n      throw new Error(`unknown option: ${arg}`);\n    } else if (!targetArg) {\n      targetArg = arg;\n    } else {\n      throw new Error(`unexpected extra positional argument: ${arg}`);\n    }\n  }\n  return { targetArg, sourcePaths, configPath, json, help: false };\n}\n\n/** Return the command-line usage text. */\nfunction usage() {\n  return `Usage: node verify-cv-facts.mjs <generated-document> [--source path] [--config path] [--json]\n       node verify-cv-facts.mjs --self-test\n\nChecks generated candidate-facing text for unsupported metrics and explicitly asserted\nnon-metric facts (employers, titles, and tools) absent from source files.\nDefault sources: cv.md, article-digest.md\nDefault config:  config/cv-facts.json (optional)`;","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/verify-cv-facts.mjs#L420-L456","documentation":"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.","triggerScenarios":"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.","commonSituations":"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 '--'.","solutions":["Run `node verify-cv-facts.mjs --help` and use only the documented flags: --source, --config, --json, --help","Fix the typo (most often --sources -> --source)","For a target file whose name starts with '--', reference it via an absolute path or rename it"],"exampleFix":"# before\nnode verify-cv-facts.mjs --sources cv.md output/cover.md\n# after\nnode verify-cv-facts.mjs --source cv.md output/cover.md","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['--source', '--config', '--json', '--help', '-h']);\nfor (const a of process.argv.slice(2)) {\n  if (a.startsWith('--') && !ALLOWED.has(a) && !ALLOWED.has(a.split('=')[0])) {\n    console.error(`unknown option: ${a} — run --help`);\n    process.exit(2);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const { targetArg } = parseCliArgs(args);\n} catch (err) {\n  if (/^unknown option:/.test(err.message)) {\n    console.error(err.message);\n    console.error(usage());\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Check --help before adding flags remembered from other tools","Remember the only boolean flag is --json; --source/--config take values","Avoid filenames starting with '--', or reference them by absolute path"],"tags":["cli","argument-parsing","usage-error","unknown-flag"],"backgroundTag":"unknown-cli-option","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}