Egonex-AI/Understand-Anything · error · CliUsageError
${flag} requires a value
Error message
${flag} requires a value What it means
CliUsageError thrown by the takeValue helper when a flag that expects a following argument (--repo, --output/-o, --label, --concurrency) is followed by a missing value or a value that itself starts with '--'. It prevents silently consuming the next flag as a value.
Source
Thrown at scripts/lib/large-repo-benchmark.mjs:131
constructor() {
super('Unable to remove temporary benchmark artifacts');
this.name = 'BenchmarkArtifactCleanupError';
}
}
export function cleanupBenchmarkArtifacts(artifactRoot, operations = {}) {
const remove = operations.rmSync ?? rmSync;
try {
remove(artifactRoot, { recursive: true, force: true });
} catch {
throw new BenchmarkArtifactCleanupError();
}
}
function takeValue(argv, index, flag) {
const value = argv[index + 1];
if (!value || value.startsWith('--')) {
throw new CliUsageError(`${flag} requires a value`);
}
return value;
}
function parseConcurrency(value) {
return /^[0-9]+$/.test(value) ? Number(value) : Number.NaN;
}
function canonicalizePhysicalPath(pathValue) {
const lexicalPath = resolve(withoutExtendedWindowsPrefix(pathValue));
const missingComponents = [];
let existingAncestor = lexicalPath;
let ancestorExists = existsSync(existingAncestor);
while (!ancestorExists) {
const parent = dirname(existingAncestor);
if (parent === existingAncestor) break;
missingComponents.unshift(basename(existingAncestor));View on GitHub (pinned to 32944829e7)
Solutions
- Provide the value immediately after the flag: --output path/to/report.json.
- Use the '=' form which does not consume the next token: --output=path/to/report.json.
- Ensure the value does not itself start with '--'; if it legitimately does, use the '=' form or quote it differently.
- Run the command with --help to confirm the expected flag/value shape.
Example fix
# before node benchmark-large-repo.mjs myrepo --output # after node benchmark-large-repo.mjs myrepo --output=reports/out.json
Defensive patterns
Strategy: validation
Validate before calling
function flagHasValue(argv: string[], index: number): boolean {
const next = argv[index + 1];
return Boolean(next) && !next.startsWith('--');
} 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
- Always pair a value-expecting flag with its value, or use the '=' form.
- Print helpText() on a CliUsageError so the user sees accepted flags.
When it happens
Trigger: Passing '--output' as the last token; '--output --label x' (next token is a flag); '--concurrency' at end of argv; any flag whose value token begins with '--'.
Common situations: Typing the command without a value; copy-pasting a command where a value was dropped; a shell that swallowed an empty argument; misordering flags so one flag runs into the next.
Related errors
- Unknown option: ${arg}
- Unexpected positional argument: ${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/38e352b72dfe6713.
Report an issue: GitHub.