affaan-m/ECC · error

Missing value for --write

Error message

Missing value for --write

What it means

scripts/status.js's --write flag expects an output file path. parseArgs post-validates that if --write appears in argv, a writePath was actually parsed; otherwise it throws "Missing value for --write". Without a path the script cannot know where to save the report.

Solutions

  1. Append the output file path: `--write report.md`.
  2. Verify the variable supplying the path is non-empty before invoking.
  3. Drop --write if you only want output to stdout.

Example fix

// before
node scripts/status.js --json --write
// after
node scripts/status.js --json --write status-report.json
Defensive patterns

Strategy: validation

Validate before calling

const wIdx = process.argv.indexOf('--write');
if (wIdx !== -1 && (!process.argv[wIdx + 1] || process.argv[wIdx + 1].startsWith('--'))) {
  throw new Error('Missing value for --write');
}

Try / catch

try {
  runStatus(argv);
} catch (e) {
  if (e.message === 'Missing value for --write') {
    console.error('Usage: node scripts/status.js --json --write <output-file>');
    process.exitCode = 1;
  } else throw e;
}

Prevention

When it happens

Trigger: Running `node scripts/status.js --json --write` with no filename after --write, or `--write --limit 5` where the next token is another flag.

Common situations: Omitting the output filename; empty variable expansion for the path; copying a partial command line; flags reordered so --write is last.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/9a2f2cd4b32e4426. Report an issue: GitHub.

Appendix: source

Thrown at scripts/status.js:71

      parsed.limit = args[index + 1] || null;
      index += 1;
    } else if (arg === '--help' || arg === '-h') {
      parsed.help = true;
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }

  if (parsed.json && parsed.markdown) {
    throw new Error('Choose only one output format: --json or --markdown');
  }

  if (args.includes('--db') && !parsed.dbPath) {
    throw new Error('Missing value for --db');
  }

  if (args.includes('--write') && !parsed.writePath) {
    throw new Error('Missing value for --write');
  }

  if (args.includes('--limit') && !parsed.limit) {
    throw new Error('Missing value for --limit');
  }

  return parsed;
}

function printActiveSessions(section) {
  console.log(`Active sessions: ${section.activeCount}`);
  if (section.sessions.length === 0) {
    console.log('  - none');
    return;
  }

  for (const session of section.sessions) {
    console.log(`  - ${session.id} [${session.harness}/${session.adapterId}] ${session.state}`);

View on GitHub (pinned to 8321021c54)