{"record":{"id":"294a224a66a6e2ed","repo":"affaan-m/ECC","slug":"argument-requires-a-value","errorCode":null,"errorMessage":"${argument} requires a value.","messagePattern":"(.+?) requires a value\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/memory.js","lineNumber":110,"sourceCode":"    return { command: 'help', options: {}, positionals: [] };\n  }\n  const [command, ...args] = argv;\n  const parsed = args.reduce((state, argument, index) => {\n    if (state.skipNext) {\n      return { ...state, skipNext: false };\n    }\n    if (BOOLEAN_OPTIONS.has(argument)) {\n      return {\n        ...state,\n        options: { ...state.options, [BOOLEAN_OPTIONS.get(argument)]: true },\n      };\n    }\n    const valueKey = VALUE_OPTIONS.get(argument);\n    const repeatKey = REPEAT_OPTIONS.get(argument);\n    if (valueKey || repeatKey) {\n      const value = args[index + 1];\n      if (value === undefined || value.startsWith('--')) {\n        throw new Error(`${argument} requires a value.`);\n      }\n      return {\n        ...state,\n        options: repeatKey\n          ? appendOption(state.options, repeatKey, value)\n          : { ...state.options, [valueKey]: value },\n        skipNext: true,\n      };\n    }\n    if (argument.startsWith('-')) {\n      throw new Error(`Unknown option: ${argument}`);\n    }\n    return { ...state, positionals: [...state.positionals, argument] };\n  }, { options: {}, positionals: [], skipNext: false });\n\n  return {\n    command,\n    options: parsed.options,","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory.js#L92-L128","documentation":"scripts/memory.js's parseArgs recognizes certain options as value-taking (VALUE_OPTIONS) or repeatable (REPEAT_OPTIONS). For these, the next argv element must exist and must not look like another flag (start with '--'). If the value is missing or is itself a flag, the parser throws '<argument> requires a value.' to prevent silently consuming the wrong token.","triggerScenarios":"Running `node scripts/memory.js write --content` (nothing after the flag) or `node scripts/memory.js write --content --tags a,b` (next token is a flag).","commonSituations":"Forgetting the value at the end of a command line, intending a value that starts with '--', or quoting mistakes that split the value into multiple tokens.","solutions":["Provide the value directly after the flag: `--content \"my note\"`.","If the value itself starts with '--', quote it or use `--content=--value` style if supported by your wrapper.","Check that shell quoting preserved the value (e.g. `--content $EMPTY_VAR` yields nothing if the variable is unset).","Run the command with the intended value first in your shell history review to spot dropped tokens."],"exampleFix":"// before\nnode scripts/memory.js write --content\n// after\nnode scripts/memory.js write --content \"project decision: use Redis\"","handlingStrategy":"validation","validationCode":"const idx = args.indexOf('--content');\nif (idx !== -1 && (args[idx+1] === undefined || args[idx+1].startsWith('--'))) {\n  throw new Error('--content requires a value');\n}","typeGuard":null,"tryCatchPattern":"try { run(args); } catch (e) { if (e.message.includes('requires a value')) { console.error(`${e.message} Pass the value right after the flag.`); process.exitCode = 2; } else throw e; }","preventionTips":["Always quote option values in shell scripts","Check for unset shell variables that would expand to nothing","Keep flag-value pairs together when building argv arrays programmatically"],"tags":["cli","argument-parsing","missing-value"],"backgroundTag":"missing-required-argument","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"}