{"record":{"id":"dcc9d1718b2dd07c","repo":"affaan-m/ECC","slug":"write-requires-json-markdown-or-format-j","errorCode":null,"errorMessage":"--write requires --json, --markdown, or --format json|markdown","messagePattern":"--write requires --json, --markdown, or --format json\\|markdown","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/discussion-audit.js","lineNumber":149,"sourceCode":"    if (arg === '--use-env-github-token') {\n      parsed.useEnvGithubToken = true;\n      continue;\n    }\n\n    if (arg === '--exit-code') {\n      parsed.exitCode = true;\n      continue;\n    }\n\n    throw new Error(`Unknown argument: ${arg}`);\n  }\n\n  if (!['text', 'json', 'markdown'].includes(parsed.format)) {\n    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);\n  }\n\n  if (parsed.writePath && parsed.format === 'text') {\n    throw new Error('--write requires --json, --markdown, or --format json|markdown');\n  }\n\n  return parsed;\n}\n\nfunction buildReport(options) {\n  const repos = options.repos.length > 0 ? options.repos : DEFAULT_REPOS;\n  const repoReports = repos.map(repo => {\n    try {\n      return {\n        repo,\n        discussions: fetchDiscussionSummary(repo, options),\n      };\n    } catch (error) {\n      return {\n        repo,\n        error: error.message,\n        discussions: emptyDiscussionSummary(),","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/discussion-audit.js#L131-L167","documentation":"parseArgs in scripts/discussion-audit.js refuses to write the plain-text report to a file: --write is only allowed when the format is json or markdown, since the text report is meant for terminal display. Passing --write with default text format throws this combination error.","triggerScenarios":"Running `node scripts/discussion-audit.js --write report.txt` without also passing --json, --markdown, or --format json|markdown.","commonSituations":"Trying to save the human-readable text report; forgetting that --write needs a machine format; composing scripts that add --write without adjusting format.","solutions":["Add --json or --markdown when using --write, e.g. `--write report.md --markdown`.","Or pass `--format json --write report.json`.","If you want the text report saved, pipe stdout: `node scripts/discussion-audit.js > report.txt`."],"exampleFix":"// before\nnode scripts/discussion-audit.js --write report.txt\n// after\nnode scripts/discussion-audit.js --write report.md --markdown","handlingStrategy":"validation","validationCode":"if (argv.includes('--write') && !argv.includes('--json') && !argv.includes('--markdown') && !argv.includes('--format')) {\n  console.error('--write needs --json or --markdown');\n  process.exit(1);\n}","typeGuard":"function canWrite(argv) {\n  const fmtIdx = argv.indexOf('--format');\n  const fmt = fmtIdx !== -1 ? argv[fmtIdx + 1] : (argv.includes('--json') ? 'json' : argv.includes('--markdown') ? 'markdown' : 'text');\n  return !argv.includes('--write') || fmt !== 'text';\n}","tryCatchPattern":"try {\n  runAudit(argv);\n} catch (e) {\n  if (e.message.includes('--write requires')) {\n    console.error('Add --json or --markdown when using --write, or redirect stdout for text.');\n  } else throw e;\n}","preventionTips":["Pair --write with --json or --markdown by convention in scripts.","Use stdout redirection if you need the text report saved.","Encode this rule in any CI wrapper around the audit script."],"tags":["cli","flag-combination","validation"],"backgroundTag":"conflicting-config-options","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"}