{"record":{"id":"4b9619affb621437","repo":"affaan-m/ECC","slug":"unknown-argument-arg-4b9619","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/list-installed.js","lineNumber":35,"sourceCode":"  const args = argv.slice(2);\n  const parsed = {\n    targets: [],\n    json: false,\n    help: false,\n  };\n\n  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--target') {\n      parsed.targets.push(args[index + 1] || null);\n      index += 1;\n    } else if (arg === '--json') {\n      parsed.json = true;\n    } else if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  return parsed;\n}\n\nfunction printHuman(records) {\n  if (records.length === 0) {\n    console.log('No ECC install-state files found for the current home/project context.');\n    return;\n  }\n\n  console.log('Installed ECC targets:\\n');\n  for (const record of records) {\n    if (record.error) {\n      console.log(`- ${record.adapter.id}: INVALID (${record.error})`);\n      continue;\n    }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/list-installed.js#L17-L53","documentation":"The list-installed.js CLI parser only recognizes --target <name>, --json, and --help/-h; every other token hits the else branch and throws `Unknown argument: <arg>`. It is a strict allowlist, so typos, pluralized flags, and flags that belong to a different script all surface here. There is no positional argument support.","triggerScenarios":"Passing `--targets` (plural) instead of `--target`. Passing `--output`, `--format`, `--verbose`, or any flag from another ECC script. Leading positional like a target id. A stray value left after --target when its value was missing.","commonSituations":"Copying a command from memory and using the wrong flag name. Mixing up list-installed flags with install/uninstall script flags. A shell alias injecting extra args.","solutions":["Run `node scripts/list-installed.js --help` and use only the flags shown.","If you meant a target filter, use `--target <id>` (singular) and a value from SUPPORTED_INSTALL_TARGETS.","Remove any positional or unrecognized flag; this script takes no positionals.","If you need JSON output, combine exactly `--json` with optional `--target <id>`."],"exampleFix":"# before\nnode scripts/list-installed.js --targets claude-code --json\n\n# after\nnode scripts/list-installed.js --target claude-code --json","handlingStrategy":"validation","validationCode":"// Validate args before invoking the script.\nconst ALLOWED = new Set(['--target', '--json', '--help', '-h']);\nfunction validateListInstalledArgs(argv) {\n  for (let i = 0; i < argv.length; i++) {\n    const a = argv[i];\n    if (!ALLOWED.has(a)) throw new Error(`Unknown argument: ${a}`);\n    if (a === '--target' && (i === argv.length - 1 || argv[i + 1].startsWith('--'))) {\n      throw new Error('--target requires a value');\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try { parseArgs(process.argv); }\ncatch (err) { if (/Unknown argument/.test(err.message)) { showHelp(2); } else throw err; }","preventionTips":["Always run `--help` first when unsure of supported flags.","Use a wrapper that filters args through an allowlist.","Remember list-installed takes NO positionals and only --target/--json."],"tags":["cli","argument-parsing","usage"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}