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
- 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
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
- 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
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
- ${arg} requires a path
- unexpected extra positional argument: ${arg}
- --${name} is required
- --${name} must not contain tabs or newlines
- --${name} must be a percentage (e.g. 70 or 70%), got "${v}"
AI-assisted analysis of santifer/career-ops@60398d6549 (2026-08-20).
Data as JSON: /api/errors/006c9edc3e4a69a5.
Report an issue: GitHub.