JuliusBrussee/caveman · error
usage: import --format
Error message
usage: ${invokedCommand("audit")} import --format <fmt> <file> What it means
`auditImport` requires a file positional argument after options. `positionalAfterOptions` returns nothing when no positional file is present, so the CLI throws a usage error telling the exact expected form `caveman audit import --format <fmt> <file>`.
Solutions
- Append the file path as the final positional argument: `caveman audit import --format caveman-jsonl ./events.jsonl`.
- Run `caveman audit import` with no args to see usage and confirm argument order.
- Ensure the file path is quoted if it contains spaces.
Example fix
// before (shell) caveman audit import --format caveman-jsonl // error: usage: caveman audit import --format <fmt> <file> // after (shell) caveman audit import --format caveman-jsonl ./audit-events.jsonl
Defensive patterns
Strategy: validation
Validate before calling
// shell
[ $# -ge 1 ] && [ -f "$1" ] || { echo "usage: caveman audit import --format <fmt> <file>"; exit 1; } Prevention
- Always put the file path last in the command line.
- Quote file paths containing spaces.
- Test the import command with a small sample file before CI use.
When it happens
Trigger: Running `caveman audit import --format caveman-jsonl` (or with no arguments at all) without supplying the input file path as the trailing positional argument.
Common situations: Copy-pasting a command and dropping the file argument; putting the file path before the options in an order the parser rejects; forgetting the file because the format flag was supplied.
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
- usage: eval-import <evidence.jsonl> [--project ] [--dry-run]
- usage: verify <bundle.json> [--pubkey ]
- eval evidence batch exceeds 1000 records
- eval evidence file contains no records
- eval evidence file exceeds 4 MiB batch limit
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/381af2ce1fce3fd8.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:17576
const body = await post(`/api/v1/projects/${await projectId()}/keys`, { name: flagFrom(argv, "--name", "cli-key"), scopes: ["proxy:write", "sdk:write"] });
print(body);
}
async function audit(argv: string[]) {
if (argv[0] === "import") return auditImport(argv);
if (argv[0] === "eval-import") return auditEvalImport(argv);
if (argv[0] === "report") return get(`/api/v1/audits/${argv[1] ?? "aud_demo"}`).then(print);
return post("/api/v1/audits", { last: flagFrom(argv, "--last", "7d") }).then(print);
}
// auditImport reads a telemetry export file and POSTs it to /api/v1/imports.
// Usage: caveman audit import --format <fmt> <file> [--field-map <json>]
// The org/project scope is resolved server-side from the auth token — never
// from the file (tenant-scoped rule).
async function auditImport(argv: string[]) {
const format = flagFrom(argv, "--format", "caveman-jsonl");
const file = positionalAfterOptions(argv.slice(1), new Set(["--format", "--field-map"]));
if (!file) throw new Error(`usage: ${invokedCommand("audit")} import --format <fmt> <file>`);
const data = await readFile(file);
const cfg = await config();
const headers: Record<string, string> = {
authorization: `Bearer ${cfg.token}`,
"content-type": "application/octet-stream",
"x-cave-csrf": "cli"
};
const fieldMap = flagFrom(argv, "--field-map", "");
if (fieldMap) headers["x-cave-field-map"] = fieldMap;
const response = await fetch(`${cfg.baseURL}/api/v1/imports?format=${encodeURIComponent(format)}`, {
method: "POST",
headers,
body: data
});
print(await response.json());
}
// auditEvalImport turns newline-delimited, source-neutral eval records into oneView on GitHub (pinned to 3ee70a1026)