affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

The argument parser in discussion-audit.js has an explicit list of recognized flags: --help/-h, --format (and --format=), --json, --markdown, --write (and --write=), --repo (and --repo=), --first (and --first=), --use-env-github-token, and --exit-code. Any token that does not match one of these patterns falls through to the throw at line 141. There are no positional arguments accepted.

Source

Thrown at scripts/discussion-audit.js:141

      continue;
    }

    if (arg.startsWith('--first=')) {
      parsed.first = parseIntegerFlag(arg.slice('--first='.length), '--first');
      continue;
    }

    if (arg === '--use-env-github-token') {
      parsed.useEnvGithubToken = true;
      continue;
    }

    if (arg === '--exit-code') {
      parsed.exitCode = true;
      continue;
    }

    throw new Error(`Unknown argument: ${arg}`);
  }

  if (!['text', 'json', 'markdown'].includes(parsed.format)) {
    throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);
  }

  if (parsed.writePath && parsed.format === 'text') {
    throw new Error('--write requires --json, --markdown, or --format json|markdown');
  }

  return parsed;
}

function buildReport(options) {
  const repos = options.repos.length > 0 ? options.repos : DEFAULT_REPOS;
  const repoReports = repos.map(repo => {
    try {
      return {

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/discussion-audit.js --help` to see all accepted flags
  2. Check for typos in flag names
  3. Use the --flag=value syntax for unambiguous parsing

Example fix

// before
node scripts/discussion-audit.js --verbose
// after
node scripts/discussion-audit.js --exit-code --format json
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate all dash-prefixed arguments
const ACCEPTED_PREFIXES = ['--format=', '--write=', '--repo=', '--first='];
const ACCEPTED_FLAGS = new Set(['--help', '-h', '--format', '--json', '--markdown', '--write', '--repo', '--first', '--use-env-github-token', '--exit-code']);
const argv = process.argv.slice(2);
for (const arg of argv) {
  if (arg.startsWith('--') && !ACCEPTED_FLAGS.has(arg) && !ACCEPTED_PREFIXES.some(p => arg.startsWith(p))) {
    console.error(`Unknown argument: ${arg}`);
    usage();
    process.exit(1);
  }
}

Try / catch

try {
  const options = parseArgs(process.argv);
} catch (error) {
  if (error.message.startsWith('Unknown argument:')) {
    console.error(error.message);
    usage();
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: Passing an unsupported flag like --verbose or --output; using a flag from another script; a typo such as --exi-code instead of --exit-code; or passing a positional argument.

Common situations: Confusing flags across different ECC scripts; CI configurations with stale flags from older versions; copy-paste from documentation for a different tool.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/26c1fbe60b87fcb8. Report an issue: GitHub.