{"record":{"id":"945d85dacd89d472","repo":"affaan-m/ECC","slug":"unknown-argument-arg-945d85","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/doctor.js","lineNumber":36,"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 statusLabel(status) {\n  if (status === 'ok') {\n    return 'OK';\n  }\n\n  if (status === 'warning') {\n    return 'WARNING';\n  }\n\n  if (status === 'error') {\n    return 'ERROR';\n  }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/doctor.js#L18-L54","documentation":"The argument parser in doctor.js accepts only three flags: --target (with a value), --json (boolean), and --help/-h (boolean). Any other token — including unknown flags, positional arguments, or typos — falls through to the else branch and throws. The --target flag is special: it pushes the next argument (or null) to an array, supporting multiple --target flags.","triggerScenarios":"Passing an unsupported flag like --verbose, --output, or --format; passing a positional argument; a typo such as --targe instead of --target; or passing --target without a value (which does not throw here but pushes null, potentially failing later).","commonSituations":"Confusing doctor.js flags with those of other ECC scripts (e.g. consult.js accepts different flags); CI configurations referencing flags from a different tool; users who assume common flags like --verbose exist across all scripts.","solutions":["Run `node scripts/doctor.js --help` to see the accepted flags","Check for typos in flag names","Note that --target expects a value from SUPPORTED_INSTALL_TARGETS (claude, claude-project, cursor, etc.)"],"exampleFix":"// before\nnode scripts/doctor.js --verbose\nnode scripts/doctor.js --format json\n// after\nnode scripts/doctor.js --json --target claude","handlingStrategy":"validation","validationCode":"// Pre-validate arguments against the accepted set\nconst ACCEPTED = new Set(['--target', '--json', '--help', '-h']);\nconst argv = process.argv.slice(2);\nfor (let i = 0; i < argv.length; i++) {\n  const arg = argv[i];\n  if (!ACCEPTED.has(arg)) {\n    console.error(`Unknown argument: ${arg}`);\n    console.error('Accepted: --target <name>, --json, --help');\n    process.exit(1);\n  }\n  if (arg === '--target') i++; // skip the value\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('doctor.js accepts only: --target <name>, --json, --help');\n    process.exit(2);\n  }\n  throw error;\n}","preventionTips":["doctor.js is intentionally minimal: only --target, --json, and --help","Do not confuse its flags with other ECC scripts that accept more options","Run --help to confirm the accepted flags","Note that --target can be repeated to check multiple targets in one run"],"tags":["cli","argument-parsing","doctor"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}