{"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":"Error","httpStatus":null,"severity":"error","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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/loop-status.js#L25-L61","documentation":"readValue in scripts/loop-status.js extracts the value following a flag. If the flag is the last argument or the next token starts with '--' (i.e. looks like another flag), it throws, because the flag was given without an actual value.","triggerScenarios":"Running loop-status with a value-taking flag at the end of the command line (e.g. 'node scripts/loop-status.js --interval') or immediately followed by another flag ('--interval --watch').","commonSituations":"Forgetting the value after a flag; copying a boolean-style invocation onto a value flag; shell variable expansion to empty ('--interval $MY_INTERVAL' with unset variable) leaving nothing after the flag.","solutions":["Supply the value directly after the flag: --interval 30.","Check that any shell variable used for the value is actually set and non-empty.","Do not place another flag where a value is expected; reorder arguments.","Run with --help to see which flags require values."],"exampleFix":"// before\nnode scripts/loop-status.js --interval\n// after\nnode scripts/loop-status.js --interval 30","handlingStrategy":"try-catch","validationCode":"function flagHasValue(argv, flag) {\n  const i = argv.indexOf(flag);\n  if (i === -1) return true;\n  const next = argv[i + 1];\n  return typeof next === 'string' && next !== '' && !next.startsWith('--');\n}\n// usage: if (!flagHasValue(args, '--interval')) exit with usage error","typeGuard":null,"tryCatchPattern":"try {\n  parseArgs(args);\n} catch (err) {\n  if (String(err.message).endsWith('requires a value')) {\n    console.error(`${err.message}\\nExample: node scripts/loop-status.js --interval 30`);\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["Always place the value immediately after its flag","Use \"${VAR:-default}\" for shell variables feeding flag values","Quote values and avoid empty expansions","Verify against --help which flags take values"],"tags":["cli","argument-parsing","missing-value"],"backgroundTag":"missing-required-flag","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"}