{"record":{"id":"1cc6bc03f53465de","repo":"affaan-m/ECC","slug":"unknown-command-commandname","errorCode":null,"errorMessage":"Unknown command: ${commandName}","messagePattern":"Unknown command: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ecc.js","lineNumber":267,"sourceCode":"    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],\n    {\n      cwd: process.cwd(),\n      env: commandName === 'ito'\n        ? {\n          ...createSafeItoInvocationEnvironment(process.env, args, {\n            includeControls: true,\n          }),\n        }\n        : process.env,\n      stdio: isItoLogin || commandName === 'setup' || commandName === 'install'\n        ? 'inherit'\n        : commandName === 'memory'\n          ? ['inherit', 'pipe', 'pipe']","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/ecc.js#L249-L285","documentation":"runCommand() looks up commandName in the COMMANDS registry before spawning the script. A name absent from the registry throws 'Unknown command: <commandName>'. It is the dispatch guard for all subcommand execution.","triggerScenarios":"main() or the help-command resolution path calls runCommand('foo', ...) where 'foo' is not a key in COMMANDS in scripts/ecc.js.","commonSituations":"Stale shell completions or docs referencing removed commands, calling runCommand programmatically with an unregistered name, or a resolution bug passing an unvalidated string.","solutions":["Verify the command exists by checking the COMMANDS map in scripts/ecc.js or running `ecc --help`.","Correct the invoked command name to a registered key.","If invoked programmatically, guard with `if (COMMANDS[name])` before calling runCommand."],"exampleFix":"// before\nrunCommand('instal', args)\n// after\nif (COMMANDS['install']) runCommand('install', args)","handlingStrategy":"try-catch","validationCode":"if (!COMMANDS[commandName]) {\n  console.error(`'${commandName}' is not a registered command. See ecc --help.`);\n  process.exit(1);\n}","typeGuard":"const isRegistered = (name) => Object.prototype.hasOwnProperty.call(COMMANDS, name);","tryCatchPattern":"try {\n  process.exitCode = runCommand(name, args);\n} catch (err) {\n  if (/^Unknown command:/.test(err.message)) {\n    showHelp(1);\n  } else {\n    throw err;\n  }\n}","preventionTips":["Validate names against COMMANDS before dispatching programmatically.","Regenerate shell completions after upgrading ECC.","Use `ecc help <cmd>` to confirm a command exists before scripting it."],"tags":["cli","command-not-found","dispatch"],"backgroundTag":"command-not-found","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"}