{"record":{"id":"9229175f0264ab34","repo":"JuliusBrussee/caveman","slug":"choose-days-or-all-time","errorCode":null,"errorMessage":"choose --days or --all-time","messagePattern":"choose --days or --all-time","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/stats-cli.ts","lineNumber":54,"sourceCode":"  for (let i = 0; i < argv.length; i++) {\n    const arg = argv[i]!;\n    if (seen.has(arg)) throw new Error(`duplicate ${arg}`);\n    seen.add(arg);\n    if (valueFlags.has(arg)) {\n      const value = argv[++i];\n      if (!value || value.startsWith(\"--\") || /[\\u0000-\\u001f\\u007f]/u.test(value)) throw new Error(`${arg} requires a value`);\n      if (arg === \"--days\" && (!/^\\d+$/u.test(value) || Number(value) < 1 || Number(value) > 3660)) {\n        throw new Error(\"--days must be an integer from 1 to 3660\");\n      }\n      if (arg === \"--out\") result.out = value;\n      else result.filters.push(arg, value);\n    } else if (arg === \"--json\") result.json = true;\n    else if (arg === \"--plain\" || arg === \"--no-open\") result.plain = true;\n    else if (arg === \"--open\") result.open = true;\n    else if (arg === \"--all-time\") result.filters.push(\"--days\", \"0\");\n    else throw new Error(`unknown option ${arg}`);\n  }\n  if (seen.has(\"--days\") && seen.has(\"--all-time\")) throw new Error(\"choose --days or --all-time\");\n  if (result.plain && result.open) throw new Error(\"choose --plain or --open\");\n  if (result.json && result.open) throw new Error(\"--json cannot open a browser\");\n  return result;\n}\n\ntype StatsMetrics = {\n  requests: number;\n  successful_requests: number;\n  failed_requests: number;\n  input_tokens: number;\n  output_tokens: number;\n  cache_read_tokens: number;\n  cache_write_tokens: number;\n  complete_usage_requests: number;\n  partial_usage_requests: number;\n  measured_requests: number;\n  unmeasured_requests: number;\n  before_tokens: number;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/stats-cli.ts#L36-L72","documentation":"Option conflict in parseStatsOptions: the stats window must be unambiguous, so --days (bounded recent window) and --all-time (full history) cannot both be passed. Neither is defaulted when the other is present, and both together are rejected.","triggerScenarios":"`stats --days 30 --all-time`; a wrapper script appending --all-time on top of user-supplied --days.","commonSituations":"Defaults injected by tooling colliding with user flags; misunderstanding that --all-time overrides --days (it doesn't — it's rejected).","solutions":["Remove one of the two flags depending on the desired window","If you want everything, keep only `--all-time`; for a bounded window keep only `--days N`","In wrapper scripts, strip --all-time before appending --days (or vice versa)"],"exampleFix":"// before\nmyapp stats --days 30 --all-time\n// after\nmyapp stats --days 30","handlingStrategy":"validation","validationCode":"const a = argv.filter(x => x !== \"--all-time\");\nif (a.includes(\"--days\") && argv.includes(\"--all-time\")) throw new Error(\"pass --days or --all-time, not both\");","typeGuard":null,"tryCatchPattern":"try {\n  const opts = parseStatsOptions(argv);\n} catch (e) {\n  if (e.message === \"choose --days or --all-time\") {\n    console.error(e.message); process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Centralize time-window selection in one config value, then map to a single flag","In wrappers, strip --all-time before appending --days","Never merge flag sets from two config sources blindly"],"tags":["cli","conflicting-options"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}