{"record":{"id":"d6fdb0605273eb53","repo":"affaan-m/ECC","slug":"unknown-argument-arg-d6fdb0","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/generate-command-registry.js","lineNumber":263,"sourceCode":"  for (const { agent, count } of registry.statistics.topAgents) {\n    lines.push(`  ${agent}: ${count}`);\n  }\n\n  lines.push('', 'Top skills:');\n  for (const { skill, count } of registry.statistics.topSkills) {\n    lines.push(`  ${skill}: ${count}`);\n  }\n\n  return `${lines.join('\\n')}\\n`;\n}\n\nfunction parseArgs(argv) {\n  const allowed = new Set(['--json', '--write', '--check']);\n  const flags = new Set();\n\n  for (const arg of argv) {\n    if (!allowed.has(arg)) {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n    flags.add(arg);\n  }\n\n  return {\n    json: flags.has('--json'),\n    write: flags.has('--write'),\n    check: flags.has('--check'),\n  };\n}\n\nfunction run(argv = process.argv.slice(2), options = {}) {\n  const stdout = options.stdout || process.stdout;\n  const stderr = options.stderr || process.stderr;\n  const outputPath = options.outputPath || DEFAULT_OUTPUT_PATH;\n\n  try {\n    const args = parseArgs(argv);","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ci/generate-command-registry.js#L245-L281","documentation":"`parseArgs` in generate-command-registry.js accepts only three flags: `--json`, `--write`, `--check`. Any other CLI token throws `Unknown argument: <arg>`. The check runs before any work, so it fails fast on typos or unsupported options.","triggerScenarios":"Triggered by passing any flag outside the allowed set: `--help`, `-h`, `--output`, `--check-only`, positional args, `--format`, misspelled flags like `--wite`, or a value-bearing flag like `--out path.json`.","commonSituations":"A user assumes `--help` exists (it doesn't in this script). Someone passes an output path. A CI script forwards unknown args. A typo on the command line. Confusing this script's flag set with another CI script's (e.g. catalog.js supports `--md`/`--text` but this one doesn't).","solutions":["Use only `--json`, `--write`, or `--check`. To emit JSON: `--json`. To write the artifact: `--write`. To verify staleness: `--check`.","There is no `--help` in this script — read the file header comment (lines 1-10) for usage.","Remove any positional or value-bearing arguments; the script hardcodes DEFAULT_OUTPUT_PATH.","If you need a custom output path, call the exported `writeRegistry(registry, outputPath)` / `checkRegistry(registry, outputPath)` from Node instead of the CLI."],"exampleFix":"// before — passing an unsupported --output flag\nnode scripts/ci/generate-command-registry.js --output docs/other.json\n// -> Unknown argument: --output\n\n// after\nnode scripts/ci/generate-command-registry.js --write\n// or, for a custom path, call from Node:\n// node -e \"const {generateRegistry,writeRegistry}=require('./scripts/ci/generate-command-registry.js'); writeRegistry(generateRegistry(), 'docs/other.json')\"","handlingStrategy":"validation","validationCode":"const allowed = new Set(['--json', '--write', '--check']);\nconst argv = process.argv.slice(2);\nfor (const arg of argv) {\n  if (!allowed.has(arg)) {\n    console.error(`Unknown argument: ${arg}. Allowed: --json, --write, --check`);\n    process.exit(2);\n  }\n}","typeGuard":"function isAllowedArg(arg) {\n  return new Set(['--json', '--write', '--check']).has(arg);\n}","tryCatchPattern":"try {\n  run(argv);\n} catch (error) {\n  if (/Unknown argument/i.test(error.message)) {\n    console.error('Allowed flags: --json, --write, --check. No --help, no value-bearing flags.');\n  }\n  throw error;\n}","preventionTips":["Memorize the three allowed flags: --json (emit JSON), --write (write artifact), --check (verify staleness).","This script has no --help; consult the header comment in generate-command-registry.js for usage.","For a custom output path, import writeRegistry/checkRegistry from Node rather than using the CLI.","Do not forward args from other CI scripts without filtering."],"tags":["ci","command-registry","cli","argument-validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}