Egonex-AI/Understand-Anything · error · CliUsageError
Unexpected positional argument: ${arg}
Error message
Unexpected positional argument: ${arg} What it means
CliUsageError thrown by parseArgs when a positional (non-flag) argument appears but repoValue is already set. The command accepts exactly one positional — the repository path — and a second one is rejected as unexpected.
Source
Thrown at scripts/lib/large-repo-benchmark.mjs:241
if (arg.startsWith('--label=')) {
label = arg.slice('--label='.length);
continue;
}
if (arg === '--concurrency') {
const raw = takeValue(argv, i, '--concurrency');
concurrency = parseConcurrency(raw);
i += 1;
continue;
}
if (arg.startsWith('--concurrency=')) {
concurrency = parseConcurrency(arg.slice('--concurrency='.length));
continue;
}
if (arg.startsWith('-')) {
throw new CliUsageError(`Unknown option: ${arg}`);
}
if (repoValue) {
throw new CliUsageError(`Unexpected positional argument: ${arg}`);
}
repoValue = arg;
}
if (help) return { help: true };
if (!repoValue) throw new CliUsageError('A repository path is required');
if (outputValue === null || outputValue.trim() === '') {
throw new CliUsageError('--output is required and must be non-empty');
}
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 32) {
throw new CliUsageError('--concurrency must be an integer between 1 and 32');
}
const repoRoot = resolve(cwd, repoValue);
if (!existsSync(repoRoot)) {
throw new CliUsageError(`Repository path does not exist: ${repoValue}`);
}
if (!statSync(repoRoot).isDirectory()) {View on GitHub (pinned to 32944829e7)
Solutions
- Provide only one positional (the repository path); use --output for the report path.
- Quote or escape shell globs that expand to multiple tokens.
- Re-run with --help to confirm the single-positional contract.
- If you meant the extra token as an option value, prefix it with the correct flag.
Example fix
# before node benchmark-large-repo.mjs myrepo reports/out.json # after node benchmark-large-repo.mjs myrepo --output reports/out.json
Defensive patterns
Strategy: validation
Validate before calling
const positionals = argv.filter(a => !a.startsWith('-'));
if (positionals.length > 1) { /* reject early */ } Try / catch
try { const opts = parseArgs(argv); } catch (e) { if ((e as Error).name === 'CliUsageError') { console.error(e.message); process.exit(2); } throw e; } Prevention
- Pass exactly one positional (the repo) and use flags for everything else.
- Quote shell globs that could expand to multiple positionals.
When it happens
Trigger: Passing two repository paths; a positional argument after the repo when an option was meant to be a flag (e.g. forgetting '--' or a flag prefix); trailing tokens that are not options.
Common situations: Specifying both a source and output as positionals instead of using --output; a stray token from a shell glob; misreading the usage and supplying extra positional arguments.
Related errors
- ${flag} requires a value
- Unknown option: ${arg}
- A repository path is required
- --output is required and must be non-empty
- --concurrency must be an integer between 1 and 32
AI-assisted analysis of Egonex-AI/Understand-Anything@32944829e7 (2026-08-12).
Data as JSON: /api/errors/f77205560cfd32fe.
Report an issue: GitHub.