{"record":{"id":"e0f90b4e410695f6","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-e0f90b","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/loop-status.js","lineNumber":43,"sourceCode":"    '  --bash-timeout-seconds <n>     Age before a pending Bash call is stale (default: 1800)',\n    '  --wake-grace-multiplier <n>    ScheduleWakeup grace multiplier (default: 2)',\n    '  --now <time>                   Override current time (ISO, epoch ms, or \"now\")',\n    '  --exit-code                    Exit 2 on attention signals, 1 on scan errors',\n    '  --watch                        Refresh status until interrupted',\n    '  --watch-count <n>              Stop after n watch refreshes',\n    '  --watch-interval-seconds <n>   Seconds between watch refreshes (default: 5)',\n    '  --write-dir <dir>              Write index.json and per-session status snapshots',\n    '',\n    'Examples:',\n    '  node scripts/loop-status.js --json',\n    '  node scripts/loop-status.js --transcript ~/.claude/projects/-repo/session.jsonl'\n  ].join('\\n'));\n}\n\nfunction readValue(args, index, flagName) {\n  const value = args[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new Error(`${flagName} requires a value`);\n  }\n  return value;\n}\n\nfunction readPositiveNumber(value, flagName) {\n  const number = Number(value);\n  if (!Number.isFinite(number) || number <= 0) {\n    throw new Error(`${flagName} must be a positive number`);\n  }\n  return number;\n}\n\nfunction readPositiveInteger(value, flagName) {\n  const number = readPositiveNumber(value, flagName);\n  if (!Number.isInteger(number)) {\n    throw new Error(`${flagName} must be a positive integer`);\n  }\n  return number;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/loop-status.js#L25-L61","documentation":"readValue is the helper that consumes the token after a value-taking flag in loop-status.js. It throws when args[index+1] is missing or itself starts with '--' (i.e. looks like the next flag rather than a value). The guard prevents silently treating a flag as a value. Affects --home, --transcript, --limit, --bash-timeout-seconds, --wake-grace-multiplier, --now, --watch-count, --watch-interval-seconds, --write-dir.","triggerScenarios":"Putting a flag last with no following token: `loop-status.js --home`. Following a value flag immediately with another flag: `loop-status.js --home --json`. A copy-paste that dropped the value.","commonSituations":"Editing a long command and deleting the value. Wrapping flags across lines so the value lands in a different shell token. Assuming a flag has a default so omitting its value is fine — it is not, the value is mandatory.","solutions":["Supply an explicit value after every value-taking flag.","If you wanted the default, remove the flag entirely rather than leaving it valueless.","Quote multi-word values: `--write-dir '/some path'`.","Re-check with `--help`; only boolean flags (no value) are --json, --exit-code, --watch."],"exampleFix":"# before\nnode scripts/loop-status.js --home --json\n\n# after\nnode scripts/loop-status.js --home \"$HOME/.claude\" --json","handlingStrategy":"validation","validationCode":"// Ensure every value-taking flag has a non-flag value before running.\nconst VALUE_FLAGS = new Set(['--home','--transcript','--limit','--bash-timeout-seconds','--wake-grace-multiplier','--now','--watch-count','--watch-interval-seconds','--write-dir']);\nfunction assertValuesPresent(argv) {\n  for (let i = 0; i < argv.length; i++) {\n    if (VALUE_FLAGS.has(argv[i])) {\n      const next = argv[i + 1];\n      if (!next || 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); printHelp(2); } else throw err; }","preventionTips":["Quote multi-word values to avoid shell splitting.","In scripts, default optional values explicitly: `--home \"${HOME_DIR:-$HOME}\"`.","Remember only --json/--exit-code/--watch are value-less booleans."],"tags":["cli","argument-parsing","usage"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}