Skip to main content

Module render

Module render 

Source

Structs§

Ink
ANSI styles — cmduse’s palette, or empty strings when colour is off, so a piped run never leaks SGR escapes.

Constants§

DEFAULT_BAR_WIDTH
Gauge width for the window bars when neither config nor --bar-width says otherwise — cmduse’s own default.

Functions§

bucket_text
Spend per bucket (day or hour), oldest first — cmduse daily/hourly. lookback_ms is the read window and size_ms the bucket width (which also names the first CSV/JSON column: day for a ≥24h bucket, else hour). The Csv columns are that key plus the store’s numeric fields (…,requests,tokens_in,tokens_out,cache_read,cost_usd; no cache-write), the Json form {scope,source,total,days|hours}, and Table is the original framing but for Ink’s colour. Json/Csv are never coloured.
compact_line
Minimal one-line dashboard for terminals too small for the full frame: period spend, rolling windows, and the burst sparkline inlined when active. No trailing newline — the caller appends its own status line, exactly like watch_frame.
date_of
YYYY-MM-DD for a Unix day number — cmduse_core::dates::civil_from_days, so the three binaries cannot drift on the calendar.
model_report
Per-model report — ocuse model on the whole period (or one id). The machine formats project the report’s models: Json mirrors cmduse’s model --json envelope ({source, sinceMs, models:{id: totals}}, with the Go limit added), Csv is one row per model (model,requests,tokens_in,tokens_out,cache_read,cost_usd). The Table form is the caller’s — the dashboard (no id) or the single-model detail (with an id) — which needs the db path and row cap, so it is rendered there.
model_text
models_json
ocuse models --json: one JSON object per line (matching cmduse’s models --json), each model’s id, name, $/1M rates, plan limit (null when not granted) and the granted verdict.
models_text
ocuse models: the Go catalogue for one plan — name, id, $/1M in / out / cache-read, and that plan’s monthly limit. Without gated, every catalogued model is listed and the GRANTED column marks which the plan allows.
plans_json
The Go/Zen catalogue as one JSON object — the machine twin of plans_text: both plans (label, price, per-model monthly allowances), the shared window shares, and the Go and Zen rate tables.
plans_text
The catalogue: what each product costs and (for Go) what each plan allows.
render_json
Machine-readable projection: totals plus the per-model breakdown.
render_text
limit rows to show; usize::MAX for all.
session_text
Spend per session, newest first. The Csv form is one row per session (session,requests,tokens_in,tokens_out,cache_read,cost_usd), Json a {scope,source,sessions} object whose entries add the last-used instant and the distinct-model count; Table keeps its own (last, models) columns.
statusline_json
ocuse statusline --json: the same numbers the template resolves, in one object — plan and period label, period/month spend, the two rolling windows, and the top model. The *Cap keys are retired (always null): Go grants limits per model, so no account-wide pool exists, and the summed ceiling they carried read as a budget the console does not have.
statusline_template
ocuse’s statusline: cmduse’s {key} template engine (report_render:: render_template) resolved against this report’s own placeholders, so both binaries are driven by statusline_template in their config.
watch_frame
One watch frame: the dashboard, then a burst sparkline when the 5-hour spend has moved since the previous refresh. No trailing newline — the caller appends its own status line and redraw_frame (cmduse’s) parks the cursor there, which is what lets the countdown rewrite a single line per second.