{"record":{"id":"5ef5d59bdb0ae03e","repo":"affaan-m/ECC","slug":"flagname-requires-a-value-5ef5d5","errorCode":null,"errorMessage":"${flagName} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":53,"sourceCode":"    '  --markdown                 Alias for --format markdown',\n    '  --write <path>             Write json or markdown output to a file',\n    '  --root <dir>               Repository root to inspect (default: cwd)',\n    '  --repo <owner/repo>        GitHub repo to inspect; repeatable',\n    '  --skip-github              Skip live GitHub queue/discussion checks',\n    '  --max-open-prs <n>         Fail when open PR count is above n (default: 20)',\n    '  --max-open-issues <n>      Fail when open issue count is above n (default: 20)',\n    '  --max-dirty-files <n>      Fail when blocking dirty file count is above n (default: 0)',\n    '  --allow-untracked <path>   Ignore untracked files under path; repeatable',\n    '  --use-env-github-token     Keep GITHUB_TOKEN when invoking gh',\n    '  --exit-code                Return 2 when the audit is not ready',\n    '  --help, -h                 Show this help',\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 parseIntegerFlag(value, flagName) {\n  const parsed = Number.parseInt(value, 10);\n  if (!Number.isFinite(parsed) || parsed < 0) {\n    throw new Error(`Invalid ${flagName}: ${value}`);\n  }\n  return parsed;\n}\n\nfunction parseArgs(argv) {\n  const args = argv.slice(2);\n  const parsed = {\n    allowUntracked: [],\n    exitCode: false,\n    format: 'text',","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/platform-audit.js#L35-L71","documentation":"readValue is the platform-audit CLI's helper for consuming a flag's value: it looks at the next argv element and rejects it if missing or if it begins with '--' (i.e. the next thing is another flag, not a value). It throws '<flagName> requires a value' so the audit exits with a clear usage error instead of silently parsing a flag as a value.","triggerScenarios":"Running `node scripts/platform-audit.js --output` (nothing after the flag), `--format` followed immediately by another flag like `--json`, or a value that legitimately starts with '--'.","commonSituations":"Truncated command from docs where the value placeholder was dropped; a boolean-style habit (`--format --json`) from tools where flags are self-contained; environment-substituted values that expanded to empty (`--output $AUDIT_OUT` with the var unset) so the next token is another flag.","solutions":["Supply the value right after the flag with a single space: `--format json`, `--output audit.md`.","If the value may start with '--' (e.g. `--label --keep`), use `=` syntax if supported or quote/reorder so the parser sees a non-flag token.","Check shell variables for empty expansion before running: `: \"${AUDIT_OUT:?output path required}\"`.","Run with no flags to see usage text listing which flags take values."],"exampleFix":"# before (value missing / looks like a flag)\nnode scripts/platform-audit.js --format --json\n\n# after\nnode scripts/platform-audit.js --format json","handlingStrategy":"validation","validationCode":"# ensure value-bearing flags have a non-flag token after them\n[[ -n \"${OUTPUT:-}\" && \"${OUTPUT:0:2}\" != '--' ]] || { echo '--output requires a value'; exit 2; }","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseArgs(process.argv);\n} catch (err) {\n  if (/requires a value/.test(err.message)) {\n    console.error(`${err.message}\\nUsage: node scripts/platform-audit.js --output <path> --format json`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Put values directly after flags: `--format json`, never `--format --json`.","Check env-var-backed values for empty expansion before invoking.","Wrap the CLI in scripts that assert required values first.","Use = syntax where supported to make flag/value pairing explicit."],"tags":["cli","argument-parsing","platform-audit"],"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"}