{"record":{"id":"b7c01de2ccda9a5c","repo":"Yeachan-Heo/oh-my-codex","slug":"flag-requires-a-value","errorCode":null,"errorMessage":"${flag} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/capabilities.ts","lineNumber":119,"sourceCode":"      case \"--lockfile\":\n        parsed.lockfile = requireValue(args, index, arg);\n        index += 1;\n        break;\n      case \"--observations\":\n        parsed.observations = requireValue(args, index, arg);\n        index += 1;\n        break;\n      default:\n        if (arg.startsWith(\"--\")) throw new Error(`Unknown capabilities option: ${arg}`);\n        break;\n    }\n  }\n  return parsed;\n}\n\nfunction requireValue(args: string[], index: number, flag: string): string {\n  const value = args[index + 1];\n  if (!value || value.startsWith(\"--\")) throw new Error(`${flag} requires a value`);\n  return value;\n}\n\nfunction printResult(result: unknown, json: boolean): void {\n  if (json) {\n    console.log(JSON.stringify(result, null, 2));\n    return;\n  }\n  const check = result as Partial<CapabilityCheckResult> & { lockfile?: string };\n  console.log(`${check.ok ? \"OK\" : \"FAIL\"}: capabilities ${check.ok ? \"satisfied\" : \"check failed\"}`);\n  if (check.lockfile) console.log(`lockfile: ${check.lockfile}`);\n  for (const warning of check.warnings ?? []) console.warn(`warning ${warning.code}: ${warning.message}`);\n  for (const failure of check.failures ?? []) console.error(`${failure.code}: ${failure.message}`);\n}\n","sourceCodeStart":101,"sourceCodeEnd":134,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/capabilities.ts#L101-L134","documentation":"A value-taking option of the `capabilities` command (such as `--observations`) was passed as the last argument, or its next token was another `--flag`. `requireValue` refuses missing or flag-like values.","triggerScenarios":"`omx capabilities get --observations` with nothing after it, or `omx capabilities get --observations --json` where the value slot is occupied by another flag.","commonSituations":"Forgetting the argument value in shell scripts, option ordering mistakes, or quoting bugs that swallow the value.","solutions":["Supply a concrete value right after the flag: `--observations <value>`","If the next token is a flag, reorder so the value comes immediately after its option"],"exampleFix":"# before\nomx capabilities get --observations --json\n\n# after\nomx capabilities get --json --observations my-obs","handlingStrategy":"validation","validationCode":"function hasValueAfter(args: string[], flag: string): boolean {\n  const i = args.indexOf(flag);\n  if (i === -1) return true;\n  const next = args[i + 1];\n  return !!next && !next.startsWith('--');\n}\nif (!hasValueAfter(args, '--observations')) {\n  console.error('--observations needs a value'); process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await capabilitiesCommand(args);\n} catch (e) {\n  if (/requires a value/.test((e as Error).message)) { /* prompt user for the missing value */ }\n  else throw e;\n}","preventionTips":["Always place a value immediately after value-taking flags","Add shell completion or arg linting to scripts"],"tags":["cli","missing-argument","argument-validation"],"backgroundTag":"cli-flag-missing-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}