{"record":{"id":"4037cc8e6037a04c","repo":"affaan-m/ECC","slug":"unknown-argument-arg-4037cc","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/consult.js","lineNumber":225,"sourceCode":"  for (let index = 0; index < args.length; index += 1) {\n    const arg = args[index];\n\n    if (arg === '--json') {\n      parsed.json = true;\n    } else if (arg === '--target') {\n      if (!args[index + 1] || args[index + 1].startsWith('-')) {\n        throw new Error('Missing value for --target');\n      }\n      parsed.target = args[index + 1];\n      index += 1;\n    } else if (arg === '--limit') {\n      if (!args[index + 1]) {\n        throw new Error('Missing value for --limit');\n      }\n      parsed.limit = Math.min(parsePositiveInteger(args[index + 1], '--limit'), MAX_LIMIT);\n      index += 1;\n    } else if (arg.startsWith('-')) {\n      throw new Error(`Unknown argument: ${arg}`);\n    } else {\n      parsed.queryParts.push(arg);\n    }\n  }\n\n  if (!SUPPORTED_INSTALL_TARGETS.includes(parsed.target)) {\n    throw new Error(\n      `Unknown install target: ${parsed.target}. Expected one of ${SUPPORTED_INSTALL_TARGETS.join(', ')}`\n    );\n  }\n\n  parsed.query = parsed.queryParts.join(' ').trim();\n  return parsed;\n}\n\nfunction commandFor(kind, id, target) {\n  if (kind === 'profile') {\n    return `npx ecc-universal install --profile ${id} --target ${target}`;","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/consult.js#L207-L243","documentation":"In consult.js parseArgs(), any token that starts with '-' and is not --json, --target, --limit, --help, or -h falls through to the else-if branch `arg.startsWith('-')` and throws. This catches typos, unsupported flags, and single-dash variants of flags that expect double-dash (e.g. -limit instead of --limit). Positional arguments (query words) that don't start with '-' are fine.","triggerScenarios":"Passing a flag like --verbose or --output that is not supported; using a typo such as --targe instead of --target; passing a single-dash variant like -json instead of --json.","commonSituations":"Confusing this script's flags with those of another ECC script; outdated documentation referencing removed flags; shell tab-completion inserting a wrong flag.","solutions":["Run `node scripts/consult.js --help` to see the four accepted flags: --json, --target, --limit, --help","Check for typos in flag names","Remember only the query is positional — all options require double-dash"],"exampleFix":"// before\nnode scripts/consult.js --verbose security reviews\n// after\nnode scripts/consult.js --json security reviews","handlingStrategy":"validation","validationCode":"// Pre-validate that all dash-prefixed arguments are recognized\nconst ACCEPTED = new Set(['--json', '--target', '--limit', '--help', '-h']);\nconst argv = process.argv.slice(2);\nfor (const arg of argv) {\n  if (arg.startsWith('-') && !ACCEPTED.has(arg)) {\n    console.error(`Unknown argument: ${arg}`);\n    console.error('Accepted flags: --json, --target <name>, --limit <n>, --help');\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const options = parseArgs(process.argv);\n} catch (error) {\n  if (error.message.startsWith('Unknown argument:')) {\n    console.error(error.message);\n    console.error('Accepted: --json, --target <name>, --limit <n>, --help');\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["consult.js accepts only four flags: --json, --target, --limit, --help","All other tokens are treated as query words — only dash-prefixed tokens trigger this error","Run --help to confirm the accepted flag set"],"tags":["cli","argument-parsing","consult"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}