{"record":{"id":"724da75f0d13d262","repo":"affaan-m/ECC","slug":"unknown-command-firstarg","errorCode":null,"errorMessage":"Unknown command: ${firstArg}","messagePattern":"Unknown command: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ecc.js","lineNumber":246,"sourceCode":"    };\n  }\n\n  if (COMMANDS[firstArg]) {\n    return {\n      mode: 'command',\n      command: firstArg,\n      args: restArgs,\n    };\n  }\n\n  const knownLegacyLanguages = listAvailableLanguages();\n  const shouldTreatAsImplicitInstall = (\n    firstArg.startsWith('-')\n    || knownLegacyLanguages.includes(firstArg)\n  );\n\n  if (!shouldTreatAsImplicitInstall) {\n    throw new Error(`Unknown command: ${firstArg}`);\n  }\n\n  return {\n    mode: 'command',\n    command: 'install',\n    args,\n  };\n}\n\nfunction runCommand(commandName, args) {\n  const command = COMMANDS[commandName];\n  if (!command) {\n    throw new Error(`Unknown command: ${commandName}`);\n  }\n  const isItoLogin = commandName === 'ito' && getInvocationCommand(args) === 'login';\n  const result = spawnSync(\n    process.execPath,\n    [path.join(__dirname, command.script), ...args],","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ecc.js#L228-L264","documentation":"Thrown by the ECC CLI entrypoint (scripts/ecc.js) when the first positional argument is not a known subcommand, not a recognized legacy language, and does not start with a dash (flag). The CLI tries to resolve the first argument as a command name, then falls back to treating it as an implicit 'install' if it looks like a flag or a known language; anything else is rejected as unknown.","triggerScenarios":"Running `node scripts/ecc.js <something>` where `<something>` is neither a registered command in COMMANDS, nor a flag (does not start with '-'), nor a value returned by listAvailableLanguages(). For example `npx ecc foo` or a typo like `npx ecc instal` (missing 'l').","commonSituations":"Typos in subcommand names (e.g. 'instal' instead of 'install'), using a command that was removed or renamed in a newer ECC version, or passing a positional that the user thinks is valid but is not in the legacy languages list.","solutions":["Run `node scripts/ecc.js --help` to see the list of valid commands.","Check for typos in the command name you passed as the first argument.","If you expect it to be treated as an install target, verify it appears in listAvailableLanguages() or prefix it with a dash flag.","Update ECC to the latest version in case the command was renamed or added."],"exampleFix":"// before\nnode scripts/ecc.js instal typescript\n// after\nnode scripts/ecc.js install typescript","handlingStrategy":"validation","validationCode":"const knownCommands = Object.keys(COMMANDS);\nconst knownLangs = listAvailableLanguages();\nif (!knownCommands.includes(firstArg) && !firstArg.startsWith('-') && !knownLangs.includes(firstArg)) {\n  console.error(`Invalid command: ${firstArg}. Available: ${knownCommands.join(', ')}`);\n  process.exit(1);\n}","typeGuard":"function isKnownCommand(arg, COMMANDS, languages) {\n  return Object.prototype.hasOwnProperty.call(COMMANDS, arg)\n    || arg.startsWith('-')\n    || languages.includes(arg);\n}","tryCatchPattern":null,"preventionTips":["Always run with --help first when unsure of available commands.","Wrap the CLI in a shell function that validates the first arg against --help output.","Pin ECC to a known version so the command set does not change unexpectedly."],"tags":["cli","argument-parsing","user-input"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}