{"record":{"id":"294a224a66a6e2ed","repo":"affaan-m/ECC","slug":"argument-requires-a-value","errorCode":null,"errorMessage":"${argument} requires a value.","messagePattern":"(.+?) requires a value\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/memory.js#L92-L128","documentation":"In memory.js parseArgs, any flag in VALUE_OPTIONS (--body-file, --from, --limit, --source-harness, --target-harness, --title) or REPEAT_OPTIONS (--kind, --link, --scope, --tag, --target) must be followed by a value token. If the next token is undefined (end of args) or starts with '--' (looks like another flag), the parser throws `${argument} requires a value.` The guard prevents consuming the next flag as a value.","triggerScenarios":"Ending the command with a value flag: `memory save --title`. Placing two value flags back to back: `memory save --title --body-file x.md`. A negative-style value the user forgot to quote that the parser sees as flag-like.","commonSituations":"Editing a long memory command and dropping a value. Scripted invocation where a variable expanded to empty, so the flag is followed by the next flag.","solutions":["Provide a value after each value/repeat flag.","Quote values containing special characters: `--title \"Release 2025-08\"`.","If a shell variable may be empty, default it: `--title \"${TITLE:?title required}\"`.","Run `memory` with no args / --help to see which flags need values."],"exampleFix":"# before\necc memory save --title --body-file notes.md\n\n# after\necc memory save --title \"Release notes\" --body-file notes.md","handlingStrategy":"validation","validationCode":"const VALUE_OR_REPEAT = new Set(['--body-file','--from','--limit','--source-harness','--target-harness','--title','--kind','--link','--scope','--tag','--target']);\nfunction assertMemoryValuesPresent(argv) {\n  for (let i = 0; i < argv.length; i++) {\n    if (VALUE_OR_REPEAT.has(argv[i])) {\n      const next = argv[i + 1];\n      if (next === undefined || next.startsWith('--')) throw new Error(`${argv[i]} requires a value.`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try { parseArgs(process.argv); }\ncatch (err) { if (/requires a value\\./.test(err.message)) { console.error(err.message); usage(2); } else throw err; }","preventionTips":["Quote values, especially ones containing spaces or punctuation.","Use `${VAR:?msg}` so empty shell variables fail early.","Run `ecc memory` with no args to see which flags require values."],"tags":["cli","argument-parsing","memory-vault","usage"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}