{"record":{"id":"36e6b4222c0f1084","repo":"affaan-m/ECC","slug":"unknown-argument-arg-36e6b4","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/catalog.js","lineNumber":92,"sourceCode":"      parsed.help = true;\n    } else if (arg === '--json') {\n      parsed.json = true;\n    } else if (arg === '--family') {\n      if (!args[index + 1]) {\n        throw new Error('Missing value for --family');\n      }\n      parsed.family = normalizeFamily(args[index + 1]);\n      index += 1;\n    } else if (arg === '--target') {\n      if (!args[index + 1]) {\n        throw new Error('Missing value for --target');\n      }\n      parsed.target = args[index + 1];\n      index += 1;\n    } else if (parsed.command === 'show' && !parsed.componentId) {\n      parsed.componentId = arg;\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  return parsed;\n}\n\nfunction printProfiles(profiles) {\n  console.log('Install profiles:\\n');\n  for (const profile of profiles) {\n    console.log(`- ${profile.id} (${profile.moduleCount} modules)`);\n    console.log(`  ${profile.description}`);\n  }\n}\n\nfunction printComponents(components) {\n  console.log('Install components:\\n');\n  for (const component of components) {\n    console.log(`- ${component.id} [${component.family}]`);","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/catalog.js#L74-L110","documentation":"After recognized flags, parseArgs only allows a bare positional argument when the command is 'show' and no componentId has been captured yet. Any other unrecognized token reaches the else branch and throws `Unknown argument: ${arg}`, protecting users from silently ignored typos.","triggerScenarios":"Typo'd flags (e.g. `--famil skill`), passing a positional to commands other than 'show' (e.g. `catalog list myid`), passing a second positional to `show`, or mis-quoted arguments splitting into stray tokens.","commonSituations":"Shell word-splitting introducing extra tokens; muscle-memory positionals like `catalog list component-xyz` (list takes no positional); deprecated/renamed flags from older docs.","solutions":["Fix or remove the unrecognized token — run `catalog --help` to list valid flags","Move positionals: only `catalog show <componentId>` accepts a positional ID","Quote arguments with spaces so they don't split into extra tokens","If a flag was renamed, use the new spelling"],"exampleFix":"// before\nnode scripts/catalog.js list my-component\n// Error: Unknown argument: my-component\n// after\nnode scripts/catalog.js show my-component","handlingStrategy":"validation","validationCode":"const KNOWN = ['--help','-h','--json','--family','--target'];\nconst bad = process.argv.slice(3).filter(a => a.startsWith('--') && !KNOWN.includes(a));\nif (bad.length) { console.error(`Unknown flags: ${bad.join(' ')}`); process.exit(2); }","typeGuard":null,"tryCatchPattern":"try {\n  const options = parseArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message.startsWith('Unknown argument')) {\n    console.error(`${err.message} — run 'catalog --help' for valid flags`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Verify flag spellings against --help before adding to scripts","Remember positionals are only accepted by 'show'","Quote args to avoid shell word-splitting","Keep team docs in sync with the current CLI surface"],"tags":["cli","argument-parsing","unknown-flag"],"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"}