{"record":{"id":"a3f6621a97a19b90","repo":"can1357/oh-my-pi","slug":"expected-argname-to-be-one-of-desc-optio","errorCode":null,"errorMessage":"Expected ${argName} to be one of: ${[...desc.options].join(\", \")}; got \"${argVal}\"","messagePattern":"Expected (.+?) to be one of: (.+?); got \"(.+?)\"","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/cli.ts","lineNumber":280,"sourceCode":"\t\tfor (const [argName, desc] of Object.entries(argDefs)) {\n\t\t\tif (desc.multiple) {\n\t\t\t\tconst val = positionals.slice(posIdx);\n\t\t\t\targs[argName] = val.length > 0 ? val : undefined;\n\t\t\t\tposIdx = positionals.length;\n\t\t\t} else {\n\t\t\t\tconst val = positionals[posIdx];\n\t\t\t\targs[argName] = val;\n\t\t\t\tposIdx++;\n\t\t\t}\n\t\t\t// Validate required\n\t\t\tif (desc.required && args[argName] === undefined) {\n\t\t\t\tthrow new CliUsageError(`Missing required argument: ${argName}`);\n\t\t\t}\n\t\t\t// Validate options constraint\n\t\t\tconst argVal = args[argName];\n\t\t\tif (argVal !== undefined && desc.options && typeof argVal === \"string\") {\n\t\t\t\tif (!desc.options.includes(argVal)) {\n\t\t\t\t\tthrow new CliUsageError(\n\t\t\t\t\t\t`Expected ${argName} to be one of: ${[...desc.options].join(\", \")}; got \"${argVal}\"`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { flags, args, argv: positionals } as never;\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Help rendering\n// ---------------------------------------------------------------------------\n\n/** Render full root help: header, default command details, subcommand list. */\nexport function renderRootHelp(config: CliConfig<CommandMetadata>): void {\n\tconst { bin, version, commands } = config;\n\tconst lines: string[] = [];","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/cli.ts#L262-L298","documentation":"parse() enforces the `options` constraint on positional arguments: a required or optional positional whose value is not among the declared allowed strings throws a CliUsageError listing the valid choices.","triggerScenarios":"Passing a positional value not in the argument's declared options set, e.g. `<env>` positional given \"prod\" when options are [\"dev\",\"staging\"].","commonSituations":"Users using synonyms or abbreviations for enum-like positionals, case mismatches, or values valid in a previous CLI version.","solutions":["Use one of the allowed values exactly as listed in the error.","Match case and spelling precisely (comparison is exact string inclusion).","Run --help to see valid positional values.","Extend desc.options in the arg definition if the value should be accepted."],"exampleFix":"// before\ncli.parse(['prod']); // Expected env to be one of: dev, staging\n// after\ncli.parse(['staging']);","handlingStrategy":"validation","validationCode":"const allowedEnvs = ['dev', 'staging'];\nif (!allowedEnvs.includes(envArg)) {\n  throw new Error(`env must be one of: ${allowedEnvs.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const { env } = cli.parse(argv);\n} catch (err) {\n  if (err instanceof CliUsageError && err.message.includes('to be one of')) {\n    console.error(err.message);\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Use exact values from --help for enum-like positionals.","Avoid abbreviations and synonyms for constrained arguments.","Update scripts when allowed value sets change between versions."],"tags":["cli","validation","enum","positional-args"],"backgroundTag":"invalid-enum-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}