affaan-m/ECC · error
Unknown argument
Error message
Unknown argument: ${arg} What it means
parseArgs walks platform-audit's argv and throws `Unknown argument: <arg>` for any token that does not match a recognized flag. This strict whitelist prevents typos from being silently ignored — e.g. passing --outdir when the tool expects --output would otherwise run the audit with defaults.
Solutions
- Run the script with --help (or no args) and use only the listed flags.
- Fix the typo — common ones: --output not --out, --format not --fmt.
- Quote values containing spaces so they don't split into stray tokens: `--output "my report.md"`.
- Check the current script source (the parseArgs chain in scripts/platform-audit.js) for the exact accepted flags if docs are outdated.
Example fix
# before (typo silently would be ignored elsewhere; here it throws) node scripts/platform-audit.js --outpt report.json # after node scripts/platform-audit.js --output report.json --format json
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN = new Set(['--output','--format','--json','--markdown','--exit-code','--write']);
const bad = process.argv.slice(2).filter(a => a.startsWith('--') && !KNOWN.has(a));
if (bad.length) { console.error(`unknown flags: ${bad.join(', ')}`); process.exit(2); } Try / catch
try {
const parsed = parseArgs(process.argv);
} catch (err) {
if (/^Unknown argument/.test(err.message)) {
console.error(`${err.message}\nRun with no args to see usage.`);
process.exit(2);
}
throw err;
} Prevention
- Check the script's usage/help before inventing flag names.
- Quote values with spaces so word-splitting doesn't create stray tokens.
- Don't copy flags between different ECC scripts — each has its own whitelist.
- After upgrades, re-verify flags against the current parseArgs source.
When it happens
Trigger: Invoking the script with a misspelled flag (--markdownx, --outpt), a flag from a different tool, an extra positional word ('node scripts/platform-audit.js run --json'), or a stray value quoted as its own token.
Common situations: Muscle memory from other audit tools' flag names; copy-pasting commands between ECC scripts with different flag sets; shell word-splitting inserting extra tokens from unquoted variables; upgrading ECC and using a renamed/removed flag from an old blog post.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- requires a value
- Invalid
- requires a value.
- does not accept positional arguments.
- --exit-code with --watch requires --watch-count so the…
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/4e31f22d11b425d7.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/platform-audit.js:202
continue;
}
if (arg.startsWith('--max-dirty-files=')) {
parsed.thresholds.maxDirtyFiles = parseIntegerFlag(arg.slice('--max-dirty-files='.length), '--max-dirty-files');
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');
}
parsed.allowUntracked = parsed.allowUntracked.map(normalizeRelativePrefix);
return parsed;
}
function normalizeRelativePrefix(value) {
return String(value || '')
.replace(/\\/g, '/')View on GitHub (pinned to 8321021c54)