{"record":{"id":"3e787f1f5639c825","repo":"affaan-m/ECC","slug":"unknown-argument-arg-3e787f","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/harness-adapter-compliance.js","lineNumber":56,"sourceCode":"    }\n\n    if (arg.startsWith('--format=')) {\n      parsed.format = arg.slice('--format='.length).toLowerCase();\n      continue;\n    }\n\n    if (arg === '--root') {\n      parsed.root = path.resolve(args[index + 1] || process.cwd());\n      index += 1;\n      continue;\n    }\n\n    if (arg.startsWith('--root=')) {\n      parsed.root = path.resolve(arg.slice('--root='.length));\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  parsed.root = path.resolve(parsed.root);\n  return parsed;\n}\n\nfunction printHelp() {\n  console.log([\n    'Usage: node scripts/harness-adapter-compliance.js [options]',\n    '',\n    'Validate or render the ECC harness adapter compliance scorecard.',\n    '',\n    'Options:',\n    '  --check                 Fail if adapter records or docs are out of sync',","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/harness-adapter-compliance.js#L38-L74","documentation":"parseArgs in scripts/harness-adapter-compliance.js accepts a fixed set of flags; any argument that does not match one of the known prefixes hits the final throw `Unknown argument: <arg>`. The parser is strict: it refuses unknown flags rather than ignoring them.","triggerScenarios":"Passing a flag the script does not know (e.g. --verbose, --out=file), using a space-separated value after a flag that only supports = syntax, or misspelling a supported flag (--rooot=...).","commonSituations":"Reusing command lines from other ECC scripts with different flag sets; shell aliases appending extra flags; typos in flag names; assuming an older version supported a flag that was removed.","solutions":["Remove or correct the offending argument; run the script with no args/--help to list supported flags.","Match the exact prefix the parser checks (e.g. --root= with equals sign, not --root <value>).","Compare against a working invocation of the same script (CI config, package.json scripts, docs).","If you need a new flag, extend parseArgs rather than hoping it is accepted."],"exampleFix":"// before\nnode scripts/harness-adapter-compliance.js --root ./sub --verbose\n\n// after\nnode scripts/harness-adapter-compliance.js --root=./sub","handlingStrategy":"validation","validationCode":"const KNOWN = /^--(root=|format=|json$|text$|markdown$)/; // adjust to actual flag list\nconst bad = argv.filter((a) => a.startsWith('--') && !KNOWN.test(a));\nif (bad.length) throw new Error(`Unknown argument(s): ${bad.join(', ')}`);","typeGuard":"const isKnownFlag = (arg) =>\n  arg.startsWith('--root=') || arg.startsWith('--format=') || arg === '--help';","tryCatchPattern":"try {\n  const parsed = parseArgs(process.argv);\n} catch (e) {\n  if (e.message.startsWith('Unknown argument:')) {\n    console.error(e.message + ' — see --help for supported flags');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Run the script with --help (or no args) before adopting new flags.","Use = syntax (--root=dir) as the parser expects prefix matching.","Don't reuse flag lines from other scripts without checking they exist here.","When flags change in the parser, update package.json scripts and CI configs in the same commit."],"tags":["cli","argument-parsing","validation"],"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"}