magpie quota refresh <provider> [<account>] [--json] runs the Usage card's
refresh (RefreshUsage's path) from a terminal and prints that card alone;
no other vendor is asked. provider.RefreshReport returns the read's own
cards (refreshCards, shared with RefreshUsage), since a fresh process's
caches don't hold a partial read's subscription and plan cards. A second
refresh of the same card within 30s asks nobody and prints the kept
reading, saying so on stderr; the times live in the cache dir's
quota-refresh.json, so the gap holds across processes. --json prints
magpie quota --json's shape, with readAt and error. The account may be a
login, an alias or <provider>/<account>.
Run:
- go test -tags nogui ./internal/cli ./internal/provider ./internal/tui:
ok (provider 591s under load ~200; an earlier run hit the 600s default
timeout, the rerun with -timeout 25m passed)
- TestQuotaRefreshReadsOneCard / TestQuotaRefreshGapPerCard; with the gap
check disabled by hand the first goes red ("asked a 2 times")
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on the
three packages
- the built binary in a sandbox HOME (MAGPIE_ADDR=127.0.0.1:47614) against
a local fake balance endpoint: refresh free-relay showed 12.50; a second
run at once didn't hit the endpoint and said so; after 31s it read 11.00;
"Free Relay" resolved by name; --json carried readAt, and a 404 gave
"error": "404 Not Found"; an unknown provider exits 1.
Not tried: a real subscription (Codex, Claude) or a remote magpie's cards.
Reading from the caches instead of RefreshReport doesn't turn the test red
for a key balance (its cache holds the read in-process); the subscription
path that needs it is covered by reading only, not by a test.