{"record":{"id":"4e31f22d11b425d7","repo":"affaan-m/ECC","slug":"unknown-argument-arg-4e31f2","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":202,"sourceCode":"      continue;\n    }\n\n    if (arg.startsWith('--max-dirty-files=')) {\n      parsed.thresholds.maxDirtyFiles = parseIntegerFlag(arg.slice('--max-dirty-files='.length), '--max-dirty-files');\n      continue;\n    }\n\n    if (arg === '--use-env-github-token') {\n      parsed.useEnvGithubToken = true;\n      continue;\n    }\n\n    if (arg === '--exit-code') {\n      parsed.exitCode = true;\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json', 'markdown'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);\n  }\n\n  if (parsed.writePath && parsed.format === 'text') {\n    throw new Error('--write requires --json, --markdown, or --format json|markdown');\n  }\n\n  parsed.allowUntracked = parsed.allowUntracked.map(normalizeRelativePrefix);\n\n  return parsed;\n}\n\nfunction normalizeRelativePrefix(value) {\n  return String(value || '')\n    .replace(/\\\\/g, '/')","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/platform-audit.js#L184-L220","documentation":"parseArgs walks platform-audit's argv and throws `Unknown argument: <arg>` for any token that does not match a recognized flag. This strict whitelist prevents typos from being silently ignored — e.g. passing --outdir when the tool expects --output would otherwise run the audit with defaults.","triggerScenarios":"Invoking the script with a misspelled flag (--markdownx, --outpt), a flag from a different tool, an extra positional word ('node scripts/platform-audit.js run --json'), or a stray value quoted as its own token.","commonSituations":"Muscle memory from other audit tools' flag names; copy-pasting commands between ECC scripts with different flag sets; shell word-splitting inserting extra tokens from unquoted variables; upgrading ECC and using a renamed/removed flag from an old blog post.","solutions":["Run the script with --help (or no args) and use only the listed flags.","Fix the typo — common ones: --output not --out, --format not --fmt.","Quote values containing spaces so they don't split into stray tokens: `--output \"my report.md\"`.","Check the current script source (the parseArgs chain in scripts/platform-audit.js) for the exact accepted flags if docs are outdated."],"exampleFix":"# before (typo silently would be ignored elsewhere; here it throws)\nnode scripts/platform-audit.js --outpt report.json\n\n# after\nnode scripts/platform-audit.js --output report.json --format json","handlingStrategy":"validation","validationCode":"const KNOWN = new Set(['--output','--format','--json','--markdown','--exit-code','--write']);\nconst bad = process.argv.slice(2).filter(a => a.startsWith('--') && !KNOWN.has(a));\nif (bad.length) { console.error(`unknown flags: ${bad.join(', ')}`); process.exit(2); }","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseArgs(process.argv);\n} catch (err) {\n  if (/^Unknown argument/.test(err.message)) {\n    console.error(`${err.message}\\nRun with no args to see usage.`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Check the script's usage/help before inventing flag names.","Quote values with spaces so word-splitting doesn't create stray tokens.","Don't copy flags between different ECC scripts — each has its own whitelist.","After upgrades, re-verify flags against the current parseArgs source."],"tags":["cli","argument-parsing","platform-audit"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}