{"record":{"id":"20cdc6b08446c007","repo":"Yeachan-Heo/oh-my-codex","slug":"token-requires-a-value-sparkshell-usage","errorCode":null,"errorMessage":"${token} requires a value.\n${SPARKSHELL_USAGE}","messagePattern":"(.+?) requires a value\\.\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/sparkshell.ts","lineNumber":284,"sourceCode":"  } = options;\n\n  if (platform !== 'win32') return ['sh', '-lc', script];\n  if (commandExists('pwsh')) return ['pwsh', '-NoLogo', '-NoProfile', '-Command', script];\n  if (commandExists('powershell.exe')) return ['powershell.exe', '-NoLogo', '-NoProfile', '-Command', script];\n  return [env.ComSpec?.trim() || 'cmd.exe', '/d', '/s', '/c', script];\n}\n\nfunction stripSparkShellWrapperOptions(args: readonly string[]): string[] {\n  let index = 0;\n  while (index < args.length) {\n    const token = args[index]!;\n    if (token === '--') return [...args.slice(index + 1)];\n    if (token === '--json' || token === '--since-last' || token.startsWith('--cache=')) {\n      index += 1;\n      continue;\n    }\n    if (token === '--budget' || token === '--cache-ttl-ms' || token === '--team' || token === '--worker') {\n      if (args[index + 1] === undefined) throw new Error(`${token} requires a value.\\n${SPARKSHELL_USAGE}`);\n      index += 2;\n      continue;\n    }\n    if (token.startsWith('--budget=') || token.startsWith('--cache-ttl-ms=') || token.startsWith('--team=') || token.startsWith('--worker=')) {\n      index += 1;\n      continue;\n    }\n    return [...args.slice(index)];\n  }\n  return [];\n}\n\nexport function parseSparkShellFallbackInvocation(\n  args: readonly string[],\n  options: ParseSparkShellFallbackOptions = {},\n): SparkShellFallbackInvocation {\n  args = stripSparkShellWrapperOptions(args);\n  if (args.length === 0) {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/sparkshell.ts#L266-L302","documentation":"Argument parsing for the sparkshell wrapper: an option that requires a value (--budget, --cache-ttl-ms, --team, --worker) appears as the last token with no following value. The usage text is appended.","triggerScenarios":"Invoking sparkshell with e.g. `--team` at the end of args, or `--budget` followed by another flag position that was already consumed as separate tokens where the value token is undefined.","commonSituations":"CLI typo, scripting that builds args dynamically and drops a value, or copy-pasting a command with a truncated tail.","solutions":["Supply the missing value: `--team myteam` (or `--team=myteam`)","Prefer the `=` form (--budget=100) to make value/flag pairing unambiguous","Re-check the usage string printed in the error for supported options"],"exampleFix":"# before\nomx sparkshell --team -- npm test\n# after\nomx sparkshell --team core -- npm test","handlingStrategy":"validation","validationCode":"const VALUE_FLAGS = new Set(['--budget', '--cache-ttl-ms', '--team', '--worker']);\nfunction argsWellFormed(args: string[]): boolean {\n  for (let i = 0; i < args.length; i++) {\n    if (VALUE_FLAGS.has(args[i]) && args[i + 1] === undefined) return false;\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"catch (e) { if (String(e).includes('requires a value')) { printUsage(); exit(2); } }","preventionTips":["Prefer --flag=value syntax in scripts","Validate generated argv before spawning sparkshell"],"tags":["cli","argument-parsing","sparkshell","usage"],"backgroundTag":"missing-cli-option-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}