carlos / platform Public

carlos platform: customers and per-customer credentials

carlos platform customers create, list, show and update, and carlos
platform credentials mint, over the platform doors of Tasks 8-10. No
delete verb: customer deletion is slice 2 (Paul r3).

Human output is the Task 1 mocks from the copy constants, including the
no-catalog list, show and create. --json prints the door's reply,
indented. --ref resolves through the list door's ?ref= lookup. Sessions
come from resolveMode, so CARLOS_SERVICE_TOKEN with CARLOS_CONSOLE works
with no login. --ttl is never sent as 0, which the door reads as its
default hour.

Parity rows platform-customers-list (gap, wp-platform-customers) and
platform-customers-manage (cli-only, covers the update door); docs under
carlos platform. New copy rows pending review: FlagCreateRef,
CreateRetry, SqidRequired, SqidInvalid, docs.platform,
docs.platform_customers_retry. The code-health record gains one raised
os.Exit for the new branch's single exit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 80d60bb4b8987e9e730d390ac54682532f8220e6 parent cc34dd4
13 files changed, +1,459 −3
  • .amadan/code-health.tsv +1 −0
  • commands.go +1 −0
  • commands_test.go +3 −0
  • docs/parity.md +18 −3
  • docs/site/cli.md +27 −0
  • docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md +8 −0
  • parity/cli.tsv +5 −0
  • parity/packages.tsv +1 −0
  • parity/parity.tsv +2 −0
  • platform_cli.go +727 −0
  • platform_cli_test.go +570 −0
  • platform_copy.go +68 −0
  • testdata/clireg-golden.jsonl +28 −0

CI failed — run details

diff --git a/.amadan/code-health.tsv b/.amadan/code-health.tsv
index d9b83946d..167bda300 100644
--- a/.amadan/code-health.tsv
+++ b/.amadan/code-health.tsv
@@ -99,6 +99,7 @@ fatal . offerCreateApp log.Fatal 2
fatal . offerCreateApp log.Fatalf 2
fatal . openStore log.Fatal 2
fatal . pipelineSignedInSession log.Fatal 2
+fatal . platformCommand os.Exit 1 # raised: carlos platform (platform accounts slice 1, Task 11) is a new branch; its leaves return errors, and this is the one exit for its usage and their errors, as accountsCommand has
fatal . pointerRebinder log.Fatalf 2
fatal . printListingJSON log.Fatal 1
fatal . proofCommand log.Fatal 1
diff --git a/commands.go b/commands.go
index 538b8ce32..8caa2fa33 100644
--- a/commands.go
+++ b/commands.go
@@ -153,6 +153,7 @@ func buildCommandRoot() *clireg.Node {
linkCommand(),
linksCommand(),
servicesCommand(),
+ platformCommand(),
envCommand(),
secretsCommand(),
noHint(raw("release-keygen", box, runKeygen)),
diff --git a/commands_test.go b/commands_test.go
index c39d4dbaf..290beaba7 100644
--- a/commands_test.go
+++ b/commands_test.go
@@ -45,6 +45,9 @@ func TestTopLevelWordsUnchanged(t *testing.T) {
"canary",
// The box-local mailer (platform mail submission, Task 3).
"mailer",
+ // A platform account's customer accounts (platform accounts slice
+ // 1, Task 11).
+ "platform",
}
var got []string
for _, c := range commandRoot().Children {
diff --git a/docs/parity.md b/docs/parity.md
index 947a7ca1e..34d97debe 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -12,10 +12,10 @@ CLI rows are checked against the command registry (`parity/cli.tsv`).
|---|---:|
| both | 44 |
| partial | 9 |
-| gap | 65 |
-| cli-only | 17 |
+| gap | 66 |
+| cli-only | 18 |
| console-only | 17 |
-| Total | 152 |
+| Total | 154 |
## account
@@ -182,6 +182,13 @@ CLI rows are checked against the command registry (`parity/cli.tsv`).
| account-error-level | gap | | `POST /a/{sqid}/errors/level` | [wp-cli-verbs](#wp-cli-verbs) | The account default error level. |
| account-analytics | gap | | `POST /a/{sqid}/analytics/setting` | [wp-cli-verbs](#wp-cli-verbs) | The account default for analytics. |
+## platform
+
+| Row | Status | CLI | Console | Package | Note |
+|---|---|---|---|---|---|
+| platform-customers-list | gap | `platform customers list`<br>`platform customers show` | | [wp-platform-customers](#wp-platform-customers) | |
+| platform-customers-manage | cli-only | `platform customers create`<br>`platform customers update`<br>`platform credentials mint` | | | A platform's own servers act through the API and CLI; v1 has no pages that act in a customer account. |
+
## relay
| Row | Status | CLI | Console | Package | Note |
@@ -384,6 +391,14 @@ Discussion #742.
- `instances-import` (data), CLI has `instances import`, `instances import commit`, `instances import abort`
+<a id="wp-platform-customers"></a>
+
+### wp-platform-customers: The platform account's Customers section (platform accounts slice 3)
+
+No discussion filed yet.
+
+- `platform-customers-list` (platform), CLI has `platform customers list`, `platform customers show`
+
## Outside customer parity
### operator
diff --git a/docs/site/cli.md b/docs/site/cli.md
index 8cc1c0599..dc952b56e 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -2884,6 +2884,33 @@ carlos services create --role publish --app hello --json ci-shipper \
| jq -r .secret | carlos secrets set --app hello CARLOS_SERVICE_TOKEN -
```
+### carlos platform
+
+Runs customer accounts from a platform account: `customers` creates and manages them, and `credentials` mints a credential for deploying into one.
+
+#### carlos platform customers
+
+Creates and manages the customer accounts a platform account runs. Each customer account is a full account of its own, with nobody signed in to it.
+
+```sh
+carlos platform customers create --platform bcd --name shop --ref 4812
+carlos platform customers list --platform bcd
+carlos platform customers show --platform bcd --ref 4812
+carlos platform customers update --platform bcd --customer bdf --plan personal
+```
+
+`--ref` is your own id for the customer. Creating again with the same ref returns the same account. Without `--ref`, a create retried after a timeout can make a second account, so pass `--ref` when your server retries.
+
+#### carlos platform credentials
+
+Mints a short-lived credential for one customer account, for deploying into it.
+
+```sh
+carlos platform credentials mint --platform bcd --customer bdf --json
+```
+
+It lasts an hour unless you pass `--ttl`, up to 24 hours. It works only in that one account, and stops working when the platform’s access is turned off. Use it as `CARLOS_SERVICE_TOKEN`.
+
### carlos add
Writes a route straight into a box's registry: this hostname, served by this
diff --git a/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md b/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md
index edef9d570..d366a7433 100644
--- a/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md
+++ b/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md
@@ -1351,12 +1351,18 @@ Every row is pending copy review (Task 15). `%s`/`%d` are filled as named. CLI e
| LabelValidUntil | valid until |
| MintedToken | token |
| MintedUse | use it as CARLOS_SERVICE_TOKEN with --account %s |
+| FlagCreateRef | your own id for the customer. pass it so a retried create returns the same account |
+| CreateRetry | a create retried without --ref can make a second account.\npass --ref so a retried create returns the same account |
+| SqidRequired | %s requires an account sqid |
+| SqidInvalid | %s %q is not an account sqid |
| accounts plan: cliPlanCopySourcePlatform | set by its platform account: %s (lives in `accounts_plan_copy.go` with the other `cliPlanCopy*` constants; pre-flight C6) |
A grant with no plans (no plan catalog) prints no `LabelPlans` or `LabelDefault` line in `carlos accounts platform`; a customer with no plan gets `CreatedNoPlan`, no PLAN or USAGE column, and the bare `ShowHeading` with no `plan` line or usage section. See the Task 1 no-catalog mocks (pre-flight C17).
Task 1's UX pass (2026-11-19) changed the text of `ValueByOn`, `LabelPlans`, `LabelDefault`, `Revoked`, `ListHeading`, `ColOwned`, `LabelOwned`, `UsageNear`, `UsageOver`, `UsageOverLimit`, `Minted`, `CreatedNoPlan` and `audit.grant_no_plans`, and added these rows: `LabelReason`, `ListOver`, `ListNear`, `ShowOK`, `ShowNear`, `ShowOver`, `LabelValidUntil`. The ids `ColOwned` and `LabelOwned` are kept although the words are now “claimed”. `ShowHeading` is used only for a customer with no plan. `ListOver` and `ListNear` are appended to `ListHeading` in that order, each only when its count is non-zero.
+Task 11 added, all pending copy review: `FlagCreateRef` (`--ref` on `customers create`, where it is also what makes a retry safe: create is idempotent only on the ref, Task 8), `CreateRetry` (the last lines of `carlos platform`'s usage, which is otherwise command syntax), and `SqidRequired`/`SqidInvalid` (the CLI's refusal of a missing or malformed `--platform` or `--customer` before anything is sent, `%s` the flag; worded as the existing `--account` refusals in `store.go`).
+
Task 6 added `ReasonRequired` (the CLI's refusal of `--grant` or `--revoke` without `--reason`, before anything is sent; the text of the console's `grant.reason`), `ReasonAlone` (its refusal of `--reason` with neither, pending copy review; Task 6 fix round 1) and `Usage` (the `platform` line in `carlos accounts`' usage).
Cap names in usage reuse the approved `cliPlanCopyLimit*` labels (apps and instances, object storage, emails a day, bandwidth a month, awake hours a month); `CapPDF` is the one new label.
@@ -1368,6 +1374,8 @@ Cap names in usage reuse the approved `cliPlanCopyLimit*` labels (apps and insta
| docs.accounts_platform | `### carlos accounts platform`, then: Shows an account’s platform grant, or changes it. A platform account can create customer accounts and deploy into them for its own customers. It is a deployment-operator command. Then the three examples: show, `--grant --max-customers 50 --plans free,personal --default-plan free --reason "agreed by email"`, `--revoke --reason "..."`. Then: "Turning platform access off stops the platform’s credentials at once. Its customers’ sites keep serving." |
| docs.platform_customers | `### carlos platform customers`, then: Creates and manages the customer accounts a platform account runs. Each customer account is a full account of its own, with nobody signed in to it. Examples with `--platform bcd`: create `--name shop --ref 4812`, list, show `--ref 4812`, update `--customer bdf --plan personal`. Then: "`--ref` is your own id for the customer. Creating again with the same ref returns the same account." |
| docs.platform_credentials | `### carlos platform credentials`, then: Mints a short-lived credential for one customer account, for deploying into it. Example: `carlos platform credentials mint --platform bcd --customer bdf --json`. Then: "It lasts an hour unless you pass `--ttl`, up to 24 hours. It works only in that one account, and stops working when the platform’s access is turned off. Use it as `CARLOS_SERVICE_TOKEN`." |
+| docs.platform | `### carlos platform` (required by `internal/docsite`'s one-heading-per-top-level-command gate; Task 11 added it and moved the customers and credentials headings under it to `####`), then: "Runs customer accounts from a platform account: `customers` creates and manages them, and `credentials` mints a credential for deploying into one." |
+| docs.platform_customers_retry | Appended to docs.platform_customers by Task 11: "Without `--ref`, a create retried after a timeout can make a second account, so pass `--ref` when your server retries." |
(The docs rows describe the prose; the heading lines are fixed by `internal/docsite`. Write the paragraphs from these sentences without adding claims, and put them through the same copy review.)
diff --git a/parity/cli.tsv b/parity/cli.tsv
index a9186b8db..f0d8b0a9a 100644
--- a/parity/cli.tsv
+++ b/parity/cli.tsv
@@ -185,6 +185,11 @@ pipeline init customer - - - - -
pipeline remove customer - - - - -
pipeline set customer - - - - -
pipeline show customer - - - - -
+platform credentials mint customer - - - - -
+platform customers create customer - - - - -
+platform customers list customer - - - - -
+platform customers show customer - - - - -
+platform customers update customer - - - - -
promote customer - - - - -
proof get box-local - - - - -
proof history box-local - - - - -
diff --git a/parity/packages.tsv b/parity/packages.tsv
index c74480b03..53314f9f1 100644
--- a/parity/packages.tsv
+++ b/parity/packages.tsv
@@ -10,3 +10,4 @@ wp-fleets-relay Fleets and relay self-serve in the console 739
wp-db-run Database query and pull, non-interactive run, and door keys in the console 740
wp-terminal A browser terminal for run -it and console 741
wp-import Instance import through the console 742
+wp-platform-customers The platform account's Customers section (platform accounts slice 3)
diff --git a/parity/parity.tsv b/parity/parity.tsv
index 5dc3e7498..cc7c9f63d 100644
--- a/parity/parity.tsv
+++ b/parity/parity.tsv
@@ -252,6 +252,8 @@ demo-box demo demo POST /api/box/demo-retirements/ack ; GET /api/box/demo-build
demo-report demo demo GET /demo/report ; POST /demo/report The public form to report a demo.
# platform
+platform-customers-list platform gap platform customers list ; platform customers show wp-platform-customers
+platform-customers-manage platform cli-only platform customers create ; platform customers update ; platform credentials mint A platform's own servers act through the API and CLI; v1 has no pages that act in a customer account.
static platform asset GET /static/{hash}/{file...} Hashed static files for the pages.
healthz platform internal GET /healthz Health check for the load balancer.
alert-signing-key platform internal GET /alerts/signing-key The public key alert webhook receivers fetch.
diff --git a/platform_cli.go b/platform_cli.go
new file mode 100644
index 000000000..558331ee5
--- /dev/null
+++ b/platform_cli.go
@@ -0,0 +1,727 @@
+package main
+
+// `carlos platform customers` and `carlos platform credentials mint`: a
+// platform account creates, lists, shows and changes the customer accounts
+// it runs, and mints a short-lived credential for one of them, through the
+// platform doors (internal/console/apiplatformcustomers.go,
+// apiplatformcredentials.go; platform accounts spec §6.1, §6.2, §9.3).
+// Customer deletion is slice 2 (Paul r3), so there is no delete verb.
+//
+// Sessions come from resolveMode, so a platform's own server needs no login:
+// CARLOS_SERVICE_TOKEN (its platform credential) with CARLOS_CONSOLE.
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "flag"
+ "fmt"
+ "io"
+ "log"
+ "net/http"
+ "net/url"
+ "os"
+ "slices"
+ "strconv"
+ "strings"
+ "time"
+ "unicode/utf8"
+
+ "github.com/carlosframework/platform/internal/clireg"
+ "github.com/carlosframework/platform/internal/domains"
+)
+
+// platformCustomerView, platformUsageView, platformCustomerList,
+// platformCreateReply and platformCredentialReply mirror the console doors'
+// replies. Plan is empty for a customer with no plan row (a console with no
+// plan catalog), and such a customer has no usage.
+type platformCustomerView struct {
+ Account string `json:"account"`
+ Name string `json:"name"`
+ Ref string `json:"ref,omitempty"`
+ Plan string `json:"plan,omitempty"`
+ PlanSource string `json:"plan_source,omitempty"`
+ Claimed bool `json:"claimed"`
+ CreatedAt time.Time `json:"created_at"`
+ Usage []platformUsageView `json:"usage"`
+}
+
+// platformUsageView is one cap's usage in its current period. Level is the
+// console's capLevel: ok, warn, over or ceiling.
+type platformUsageView struct {
+ Cap string `json:"cap"`
+ Used int64 `json:"used"`
+ Limit int64 `json:"limit"`
+ Level string `json:"level"`
+ GraceEnds *time.Time `json:"grace_ends,omitempty"`
+}
+
+// platformCustomerList is the list door's reply. Count is what counts
+// against MaxCustomers: live customers and unfinished creates.
+type platformCustomerList struct {
+ Platform string `json:"platform"`
+ MaxCustomers int `json:"max_customers"`
+ Count int `json:"count"`
+ Customers []platformCustomerView `json:"customers"`
+}
+
+// platformCreateReply is the create door's reply: created is false when
+// the ref was already held, and Customer is that account.
+type platformCreateReply struct {
+ Created bool `json:"created"`
+ Customer platformCustomerView `json:"customer"`
+}
+
+type platformCredentialReply struct {
+ Token string `json:"token"`
+ Account string `json:"account"`
+ Name string `json:"name"`
+ Role string `json:"role"`
+ App string `json:"app"`
+ Rungs []string `json:"rungs"`
+ ExpiresAt time.Time `json:"expires_at"`
+}
+
+// The requests leave out what was not passed: the console reads an empty
+// field as "not given".
+type createPlatformCustomerRequest struct {
+ Name string `json:"name"`
+ Ref string `json:"ref,omitempty"`
+ Plan string `json:"plan,omitempty"`
+}
+
+type updatePlatformCustomerRequest struct {
+ Name string `json:"name,omitempty"`
+ Plan string `json:"plan,omitempty"`
+ Reason string `json:"reason,omitempty"`
+}
+
+type platformCredentialRequest struct {
+ Role string `json:"role"`
+ App string `json:"app,omitempty"`
+ Rungs []string `json:"rungs,omitempty"`
+ TTLSeconds int64 `json:"ttl_seconds"`
+}
+
+// platformUsage is what `carlos platform` prints bare or for an unknown
+// word: command syntax, and CreateRetry. Each verb's -h lists its flags,
+// --console among them.
+const platformUsage = `usage: carlos platform customers <create|list|show|update> --platform <sqid>
+ carlos platform credentials mint --platform <sqid>
+
+ customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]
+ customers list [--json]
+ customers show (--customer <sqid> | --ref <ref>) [--json]
+ customers update (--customer <sqid> | --ref <ref>)
+ [--name <name>] [--plan <plan>] [--reason <text>]
+ credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]
+ [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]
+
+` + cliPlatformCopyCreateRetry + "\n"
+
+// platformCommand is `carlos platform`. Each leaf returns its errors, and
+// OnError prints one as "platform customers show: <error>" (stderr, exit
+// 1); a bare or unknown word prints platformUsage (stderr, exit 1).
+func platformCommand() *clireg.Node {
+ const cust = clireg.Customer
+ exit := func() { os.Exit(1) }
+ usage := func(args, consumed []string) {
+ fmt.Fprint(os.Stderr, platformUsage)
+ exit()
+ }
+ leaf := func(name string, f func([]string) error) *clireg.Node {
+ return &clireg.Node{Name: name, Audience: cust, Run: clireg.RawArgsErr(f)}
+ }
+ return &clireg.Node{
+ Name: "platform",
+ Audience: cust,
+ Children: []*clireg.Node{
+ {
+ Name: "customers",
+ Audience: cust,
+ Children: []*clireg.Node{
+ leaf("create", runPlatformCustomersCreate),
+ leaf("list", runPlatformCustomersList),
+ leaf("show", runPlatformCustomersShow),
+ leaf("update", runPlatformCustomersUpdate),
+ },
+ Fallback: usage,
+ },
+ {
+ Name: "credentials",
+ Audience: cust,
+ Children: []*clireg.Node{leaf("mint", runPlatformCredentialsMint)},
+ Fallback: usage,
+ },
+ },
+ Fallback: usage,
+ OnError: func(path []string, err error) {
+ log.Printf("%s: %v", strings.Join(path, " "), err)
+ exit()
+ },
+ }
+}
+
+// platformLeaf runs a verb with no session yet: -h's ErrHelp is not an
+// error (usage on stdout, exit 0).
+func platformLeaf(f func(context.Context, *apiSession, []string, io.Writer) error, args []string) error {
+ err := f(context.Background(), nil, args, stdout)
+ if errors.Is(err, flag.ErrHelp) {
+ return nil
+ }
+ return err
+}
+
+func runPlatformCustomersCreate(args []string) error {
+ return platformLeaf(runPlatformCustomersCreateWithSession, args)
+}
+
+func runPlatformCustomersList(args []string) error {
+ return platformLeaf(runPlatformCustomersListWithSession, args)
+}
+
+func runPlatformCustomersShow(args []string) error {
+ return platformLeaf(runPlatformCustomersShowWithSession, args)
+}
+
+func runPlatformCustomersUpdate(args []string) error {
+ return platformLeaf(runPlatformCustomersUpdateWithSession, args)
+}
+
+func runPlatformCredentialsMint(args []string) error {
+ return platformLeaf(runPlatformCredentialsMintWithSession, args)
+}
+
+// platformFlags are the flags every platform verb shares: --platform and
+// --console always, --customer/--ref on the verbs that act on one
+// customer, --json where the verb prints a reply.
+type platformFlags struct {
+ command string // "platform customers show", for NeedsConsole
+ fs *flag.FlagSet
+ platform *string
+ customer *string
+ ref *string
+ console *string
+ asJSON *bool
+}
+
+func newPlatformFlags(command string, out io.Writer, handle, withJSON bool) *platformFlags {
+ fs := flag.NewFlagSet(command, flag.ContinueOnError)
+ fs.SetOutput(out)
+ pf := &platformFlags{command: command, fs: fs}
+ pf.platform = fs.String("platform", "", cliPlatformCopyFlagPlatform)
+ if handle {
+ pf.customer = fs.String("customer", "", cliPlatformCopyFlagCustomer)
+ pf.ref = fs.String("ref", "", cliPlatformCopyFlagRef)
+ }
+ if withJSON {
+ pf.asJSON = fs.Bool("json", false, cliPlatformCopyFlagJSON)
+ }
+ pf.console = consoleOption(fs, "console origin to use")
+ fs.Usage = flagUsage(fs, "")
+ return pf
+}
+
+// parse reads args and checks what can be checked before anything is
+// sent: no stray argument, a --platform sqid, and on a one-customer verb
+// exactly one of --customer (a sqid) and --ref.
+func (pf *platformFlags) parse(args []string) error {
+ if err := pf.fs.Parse(args); err != nil {
+ return err
+ }
+ if pf.fs.NArg() != 0 {
+ return fmt.Errorf("unexpected argument %q", pf.fs.Arg(0))
+ }
+ p, err := platformSqidFlag("--platform", *pf.platform)
+ if err != nil {
+ return err
+ }
+ *pf.platform = p
+ if pf.customer == nil {
+ return nil
+ }
+ *pf.customer, *pf.ref = strings.TrimSpace(*pf.customer), strings.TrimSpace(*pf.ref)
+ switch {
+ case *pf.customer != "" && *pf.ref != "":
+ return errors.New(cliPlatformCopyOneHandle)
+ case *pf.customer == "" && *pf.ref == "":
+ return errors.New(cliPlatformCopyNoHandle)
+ case *pf.customer != "":
+ _, err := platformSqidFlag("--customer", *pf.customer)
+ return err
+ }
+ return nil
+}
+
+func (pf *platformFlags) wantJSON() bool { return pf.asJSON != nil && *pf.asJSON }
+
+// session is sess, or the console session the platform doors need. The
+// "using" banner is left out under --json, so stdout is the JSON alone.
+func (pf *platformFlags) session(sess *apiSession, out io.Writer) (*apiSession, error) {
+ if sess != nil {
+ return sess, nil
+ }
+ sess, err := requirePlatformAPISession(*pf.console, pf.command)
+ if err != nil {
+ return nil, err
+ }
+ if !pf.wantJSON() {
+ printUsing(out, sess)
+ }
+ return sess, nil
+}
+
+// platformSqidFlag checks a flag that names an account by sqid.
+func platformSqidFlag(name, raw string) (string, error) {
+ v := strings.TrimSpace(raw)
+ if v == "" {
+ return "", fmt.Errorf(cliPlatformCopySqidRequired, name)
+ }
+ if !domains.ValidSqid(v) {
+ return "", fmt.Errorf(cliPlatformCopySqidInvalid, name, v)
+ }
+ return v, nil
+}
+
+// customerHandle resolves --customer or --ref to the customer's sqid. A --ref
+// goes through the list door's ?ref= lookup, whose view is returned too; a
+// --customer returns no view.
+func (pf *platformFlags) customerHandle(ctx context.Context, sess *apiSession) (string, *platformCustomerView, error) {
+ if *pf.customer != "" {
+ return *pf.customer, nil, nil
+ }
+ list, _, err := sess.platformCustomers(ctx, *pf.platform, *pf.ref)
+ if err != nil {
+ return "", nil, err
+ }
+ if len(list.Customers) == 0 {
+ return "", nil, fmt.Errorf(cliPlatformCopyNoRef, *pf.ref)
+ }
+ v := list.Customers[0]
+ return v.Account, &v, nil
+}
+
+// printPlatformJSON prints a door's reply as it came, indented.
+func printPlatformJSON(out io.Writer, body []byte) error {
+ var buf bytes.Buffer
+ if err := json.Indent(&buf, bytes.TrimSpace(body), "", " "); err != nil {
+ return fmt.Errorf("unreadable response: %w", err)
+ }
+ buf.WriteByte('\n')
+ _, err := out.Write(buf.Bytes())
+ return err
+}
+
+func runPlatformCustomersCreateWithSession(ctx context.Context, sess *apiSession, args []string, out io.Writer) error {
+ pf := newPlatformFlags("platform customers create", out, false, true)
+ name := pf.fs.String("name", "", cliPlatformCopyFlagName)
+ ref := pf.fs.String("ref", "", cliPlatformCopyFlagCreateRef)
+ plan := pf.fs.String("plan", "", cliPlatformCopyFlagPlan)
+ if err := pf.parse(args); err != nil {
+ return err
+ }
+ sess, err := pf.session(sess, out)
+ if err != nil {
+ return err
+ }
+ req := createPlatformCustomerRequest{Name: strings.TrimSpace(*name), Ref: strings.TrimSpace(*ref), Plan: strings.TrimSpace(*plan)}
+ res, body, err := sess.createPlatformCustomer(ctx, *pf.platform, req)
+ if err != nil {
+ return err
+ }
+ if pf.wantJSON() {
+ return printPlatformJSON(out, body)
+ }
+ c := res.Customer
+ switch {
+ case !res.Created:
+ fmt.Fprintf(out, cliPlatformCopyExists+"\n", c.Name, c.Account, c.Ref)
+ case c.Plan == "":
+ fmt.Fprintf(out, cliPlatformCopyCreatedNoPlan+"\n", c.Name, c.Account)
+ default:
+ fmt.Fprintf(out, cliPlatformCopyCreated+"\n", c.Name, c.Account, c.Plan)
+ }
+ return nil
+}
+
+func runPlatformCustomersListWithSession(ctx context.Context, sess *apiSession, args []string, out io.Writer) error {
+ pf := newPlatformFlags("platform customers list", out, false, true)
+ if err := pf.parse(args); err != nil {
+ return err
+ }
+ sess, err := pf.session(sess, out)
+ if err != nil {
+ return err
+ }
+ list, body, err := sess.platformCustomers(ctx, *pf.platform, "")
+ if err != nil {
+ return err
+ }
+ if pf.wantJSON() {
+ return printPlatformJSON(out, body)
+ }
+ printPlatformCustomerList(out, list)
+ return nil
+}
+
+func runPlatformCustomersShowWithSession(ctx context.Context, sess *apiSession, args []string, out io.Writer) error {
+ pf := newPlatformFlags("platform customers show", out, true, true)
+ if err := pf.parse(args); err != nil {
+ return err
+ }
+ sess, err := pf.session(sess, out)
+ if err != nil {
+ return err
+ }
+ customer, _, err := pf.customerHandle(ctx, sess)
+ if err != nil {
+ return err
+ }
+ v, body, err := sess.platformCustomer(ctx, *pf.platform, customer)
+ if err != nil {
+ return err
+ }
+ if pf.wantJSON() {
+ return printPlatformJSON(out, body)
+ }
+ printPlatformCustomer(out, v)
+ return nil
+}
+
+// runPlatformCustomersUpdateWithSession changes a customer's name, plan or
+// both. The confirmation names the customer as it was, so with --customer
+// it reads the customer first; a --ref lookup has already read it.
+func runPlatformCustomersUpdateWithSession(ctx context.Context, sess *apiSession, args []string, out io.Writer) error {
+ pf := newPlatformFlags("platform customers update", out, true, false)
+ name := pf.fs.String("name", "", cliPlatformCopyFlagName)
+ plan := pf.fs.String("plan", "", cliPlatformCopyFlagPlan)
+ reason := pf.fs.String("reason", "", cliPlatformCopyFlagReason)
+ if err := pf.parse(args); err != nil {
+ return err
+ }
+ sess, err := pf.session(sess, out)
+ if err != nil {
+ return err
+ }
+ customer, before, err := pf.customerHandle(ctx, sess)
+ if err != nil {
+ return err
+ }
+ if before == nil {
+ v, _, err := sess.platformCustomer(ctx, *pf.platform, customer)
+ if err != nil {
+ return err
+ }
+ before = &v
+ }
+ req := updatePlatformCustomerRequest{Name: strings.TrimSpace(*name), Plan: strings.TrimSpace(*plan), Reason: strings.TrimSpace(*reason)}
+ after, err := sess.updatePlatformCustomer(ctx, *pf.platform, customer, req)
+ if err != nil {
+ return err
+ }
+ if req.Name != "" {
+ fmt.Fprintf(out, cliPlatformCopyRenamed+"\n", before.Name, after.Account, after.Name)
+ }
+ if req.Plan != "" {
+ fmt.Fprintf(out, cliPlatformCopyReplanned+"\n", after.Name, after.Account, after.Plan)
+ }
+ return nil
+}
+
+func runPlatformCredentialsMintWithSession(ctx context.Context, sess *apiSession, args []string, out io.Writer) error {
+ pf := newPlatformFlags("platform credentials mint", out, true, true)
+ role := pf.fs.String("role", "publish", cliPlatformCopyFlagRole)
+ app := pf.fs.String("app", "", cliPlatformCopyFlagApp)
+ rungs := pf.fs.String("rungs", "", cliPlatformCopyFlagRungs)
+ ttl := pf.fs.Duration("ttl", time.Hour, cliPlatformCopyFlagTTL)
+ if err := pf.parse(args); err != nil {
+ return err
+ }
+ sess, err := pf.session(sess, out)
+ if err != nil {
+ return err
+ }
+ customer, _, err := pf.customerHandle(ctx, sess)
+ if err != nil {
+ return err
+ }
+ req := platformCredentialRequest{Role: strings.TrimSpace(*role), App: strings.TrimSpace(*app),
+ Rungs: commaList(*rungs), TTLSeconds: platformTTLSeconds(*ttl)}
+ res, body, err := sess.mintPlatformCredential(ctx, *pf.platform, customer, req)
+ if err != nil {
+ return err
+ }
+ if pf.wantJSON() {
+ return printPlatformJSON(out, body)
+ }
+ fmt.Fprintf(out, cliPlatformCopyMinted+"\n", res.Role, res.Name, res.Account)
+ printPlatformRows(out, " ", [][]string{
+ {cliPlatformCopyLabelValidUntil, res.ExpiresAt.UTC().Format("2 January 2006 15:04") + " UTC"},
+ {cliPlatformCopyMintedToken, res.Token},
+ })
+ _, err = fmt.Fprintf(out, cliPlatformCopyMintedUse+"\n", res.Account)
+ return err
+}
+
+// platformTTLSeconds is --ttl as the door's ttl_seconds, never 0: the door
+// reads 0 as its default hour, so a --ttl of 0 or less goes as -1 and a
+// part second rounds up, and the door refuses either with its own sentence
+// (cred.ttl) rather than minting a credential that lives longer than asked.
+func platformTTLSeconds(d time.Duration) int64 {
+ if d <= 0 {
+ return -1
+ }
+ return int64((d + time.Second - 1) / time.Second)
+}
+
+// ---- output -------------------------------------------------------------------
+
+// printPlatformRows prints rows as columns, each line indented: every cell
+// but a line's last is padded to its column's widest cell plus two spaces,
+// so a block lines up on its own and no line ends in spaces (the Task 1
+// mocks' rule).
+func printPlatformRows(w io.Writer, indent string, rows [][]string) {
+ var widths []int
+ for _, row := range rows {
+ for i, cell := range row {
+ if i == len(widths) {
+ widths = append(widths, 0)
+ }
+ widths[i] = max(widths[i], utf8.RuneCountInString(cell))
+ }
+ }
+ for _, row := range rows {
+ var b strings.Builder
+ b.WriteString(indent)
+ for i, cell := range row {
+ b.WriteString(cell)
+ if i < len(row)-1 {
+ b.WriteString(strings.Repeat(" ", widths[i]-utf8.RuneCountInString(cell)+2))
+ }
+ }
+ fmt.Fprintln(w, b.String())
+ }
+}
+
+// usageRank orders cap levels: ok, then near (warn), then over (over and
+// ceiling, the console's capLevel.over).
+func usageRank(level string) int {
+ switch level {
+ case "over", "ceiling":
+ return 2
+ case "warn":
+ return 1
+ }
+ return 0
+}
+
+// worstUsage is a customer's worst usage rank and the first cap at it.
+func worstUsage(v platformCustomerView) (int, string) {
+ rank, name := 0, ""
+ for _, u := range v.Usage {
+ if r := usageRank(u.Level); r > rank {
+ rank, name = r, u.Cap
+ }
+ }
+ return rank, name
+}
+
+// capLabel is a cap's name as people read it: the approved plan labels,
+// and CapPDF. A cap this binary does not know shows its id.
+func capLabel(id string) string {
+ switch id {
+ case "running_things":
+ return cliPlanCopyLimitRunning
+ case "storage":
+ return cliPlanCopyLimitStorage
+ case "email":
+ return cliPlanCopyLimitEmail
+ case "bandwidth":
+ return cliPlanCopyLimitBandwidth
+ case "pdf":
+ return cliPlatformCopyCapPDF
+ case "awake_hours":
+ return cliPlanCopyLimitAwake
+ case "sidecars":
+ return cliPlanCopyLimitSidecars
+ case "custom_domains":
+ return cliPlanCopyLimitDomains
+ }
+ return id
+}
+
+// capAmount renders one usage number: sizes in GB or MB, counts as they are.
+func capAmount(id string, n int64) string {
+ if id == "storage" || id == "bandwidth" {
+ return planBytes(n)
+ }
+ return strconv.FormatInt(n, 10)
+}
+
+func platformYesNo(b bool) string {
+ if b {
+ return cliPlatformCopyYes
+ }
+ return cliPlatformCopyNo
+}
+
+// printPlatformCustomerList prints the list: a heading with the count, the
+// cap and the problems (over, then near, each only when there are any),
+// then a table. PLAN and USAGE are there only when a customer has a plan.
+func printPlatformCustomerList(w io.Writer, list platformCustomerList) {
+ if len(list.Customers) == 0 {
+ fmt.Fprintln(w, cliPlatformCopyListEmpty)
+ return
+ }
+ over, near := 0, 0
+ plans := false
+ for _, c := range list.Customers {
+ switch rank, _ := worstUsage(c); rank {
+ case 2:
+ over++
+ case 1:
+ near++
+ }
+ plans = plans || c.Plan != ""
+ }
+ heading := fmt.Sprintf(cliPlatformCopyListHeading, list.Count, list.MaxCustomers)
+ if over > 0 {
+ heading += fmt.Sprintf(cliPlatformCopyListOver, over)
+ }
+ if near > 0 {
+ heading += fmt.Sprintf(cliPlatformCopyListNear, near)
+ }
+ fmt.Fprintln(w, heading)
+ head := []string{cliPlatformCopyColAccount, cliPlatformCopyColName, cliPlatformCopyColRef}
+ if plans {
+ head = append(head, cliPlatformCopyColPlan, cliPlatformCopyColOwned, cliPlatformCopyColUsage)
+ } else {
+ head = append(head, cliPlatformCopyColOwned)
+ }
+ rows := [][]string{head}
+ for _, c := range list.Customers {
+ row := []string{c.Account, c.Name, orDash(c.Ref)}
+ if !plans {
+ rows = append(rows, append(row, platformYesNo(c.Claimed)))
+ continue
+ }
+ usage := "-"
+ if c.Plan != "" {
+ switch rank, id := worstUsage(c); rank {
+ case 2:
+ usage = fmt.Sprintf(cliPlatformCopyUsageOver, capLabel(id))
+ case 1:
+ usage = fmt.Sprintf(cliPlatformCopyUsageNear, capLabel(id))
+ default:
+ usage = cliPlatformCopyUsageOK
+ }
+ }
+ rows = append(rows, append(row, orDash(c.Plan), platformYesNo(c.Claimed), usage))
+ }
+ printPlatformRows(w, "", rows)
+}
+
+// printPlatformCustomer prints one customer: a heading with its state (the
+// worst usage row; the bare name for a customer with no plan), its label
+// block, and its usage rows, problems first.
+func printPlatformCustomer(w io.Writer, v platformCustomerView) {
+ heading := cliPlatformCopyShowHeading
+ if v.Plan != "" {
+ switch rank, _ := worstUsage(v); rank {
+ case 2:
+ heading = cliPlatformCopyShowOver
+ case 1:
+ heading = cliPlatformCopyShowNear
+ default:
+ heading = cliPlatformCopyShowOK
+ }
+ }
+ fmt.Fprintf(w, heading+"\n", v.Name, v.Account)
+ var rows [][]string
+ if v.Plan != "" {
+ rows = append(rows, []string{cliPlatformCopyLabelPlan, v.Plan})
+ }
+ if v.Ref != "" {
+ rows = append(rows, []string{cliPlatformCopyLabelRef, v.Ref})
+ }
+ rows = append(rows,
+ []string{cliPlatformCopyLabelOwned, platformYesNo(v.Claimed)},
+ []string{cliPlatformCopyLabelCreated, v.CreatedAt.UTC().Format("2 January 2006")})
+ printPlatformRows(w, " ", rows)
+ if v.Plan == "" || len(v.Usage) == 0 {
+ return
+ }
+ usage := slices.Clone(v.Usage)
+ slices.SortStableFunc(usage, func(a, b platformUsageView) int { return usageRank(b.Level) - usageRank(a.Level) })
+ rows = rows[:0]
+ for _, u := range usage {
+ row := []string{capLabel(u.Cap), fmt.Sprintf(cliPlatformCopyUsageRow, capAmount(u.Cap, u.Used), capAmount(u.Cap, u.Limit))}
+ switch usageRank(u.Level) {
+ case 2:
+ if u.GraceEnds != nil {
+ row = append(row, fmt.Sprintf(cliPlatformCopyUsageOverLimit, u.GraceEnds.UTC().Format("2 January 2006")))
+ }
+ case 1:
+ row = append(row, cliPlatformCopyUsageNearLimit)
+ }
+ rows = append(rows, row)
+ }
+ fmt.Fprintln(w, cliPlatformCopyUsageHeading)
+ printPlatformRows(w, " ", rows)
+}
+
+// ---- the doors ----------------------------------------------------------------
+
+func platformCustomersPath(platform string) string {
+ return "/api/cli/platform/" + url.PathEscape(platform) + "/customers"
+}
+
+func platformCustomerPath(platform, customer string) string {
+ return platformCustomersPath(platform) + "/" + url.PathEscape(customer)
+}
+
+// platformCustomers lists the platform's customers, or with ref the one
+// holding it. Each door method returns the reply and its body, for --json.
+func (s *apiSession) platformCustomers(ctx context.Context, platform, ref string) (platformCustomerList, []byte, error) {
+ path := platformCustomersPath(platform)
+ if ref != "" {
+ path += "?ref=" + url.QueryEscape(ref)
+ }
+ status, body, err := s.getJSON(ctx, path)
+ var out platformCustomerList
+ return out, body, decodePlatformReply(status, body, err, &out)
+}
+
+func (s *apiSession) platformCustomer(ctx context.Context, platform, customer string) (platformCustomerView, []byte, error) {
+ status, body, err := s.getJSON(ctx, platformCustomerPath(platform, customer))
+ var out platformCustomerView
+ return out, body, decodePlatformReply(status, body, err, &out)
+}
+
+// createPlatformCustomer answers 201 for a new account and 200 for a ref
+// already held; both are a reply.
+func (s *apiSession) createPlatformCustomer(ctx context.Context, platform string, req createPlatformCustomerRequest) (platformCreateReply, []byte, error) {
+ status, body, err := s.postJSON(ctx, platformCustomersPath(platform), req)
+ if status == http.StatusCreated {
+ status = http.StatusOK
+ }
+ var out platformCreateReply
+ return out, body, decodePlatformReply(status, body, err, &out)
+}
+
+func (s *apiSession) updatePlatformCustomer(ctx context.Context, platform, customer string, req updatePlatformCustomerRequest) (platformCustomerView, error) {
+ status, body, err := s.patchJSON(ctx, platformCustomerPath(platform, customer), req)
+ var out platformCustomerView
+ return out, decodePlatformReply(status, body, err, &out)
+}
+
+// mintPlatformCredential answers 201 with the credential.
+func (s *apiSession) mintPlatformCredential(ctx context.Context, platform, customer string, req platformCredentialRequest) (platformCredentialReply, []byte, error) {
+ status, body, err := s.postJSON(ctx, platformCustomerPath(platform, customer)+"/credentials", req)
+ if status == http.StatusCreated {
+ status = http.StatusOK
+ }
+ var out platformCredentialReply
+ return out, body, decodePlatformReply(status, body, err, &out)
+}
diff --git a/platform_cli_test.go b/platform_cli_test.go
new file mode 100644
index 000000000..53bb88d76
--- /dev/null
+++ b/platform_cli_test.go
@@ -0,0 +1,570 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "strings"
+ "testing"
+ "time"
+)
+
+// platformDoorReply is one canned answer of the fake console.
+type platformDoorReply struct {
+ status int
+ body any
+}
+
+// platformConsole is a fake console for the platform doors: replies by
+// "METHOD /path?query", and every request it saw, in order, with its body.
+type platformConsole struct {
+ ts *httptest.Server
+ replies map[string]platformDoorReply
+ reqs []string
+ bodies []string
+}
+
+func newPlatformConsole(t *testing.T, replies map[string]platformDoorReply) *platformConsole {
+ t.Helper()
+ pc := &platformConsole{replies: replies}
+ pc.ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ key := r.Method + " " + r.URL.RequestURI()
+ pc.reqs = append(pc.reqs, key)
+ b, _ := io.ReadAll(r.Body)
+ pc.bodies = append(pc.bodies, string(b))
+ rep, ok := pc.replies[key]
+ if !ok {
+ http.NotFound(w, r)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(rep.status)
+ json.NewEncoder(w).Encode(rep.body)
+ }))
+ t.Cleanup(pc.ts.Close)
+ return pc
+}
+
+type platformVerb func(context.Context, *apiSession, []string, io.Writer) error
+
+func (pc *platformConsole) run(t *testing.T, verb platformVerb, args ...string) (string, error) {
+ t.Helper()
+ var out bytes.Buffer
+ err := verb(context.Background(), newTestSession(pc.ts.URL), args, &out)
+ return out.String(), err
+}
+
+func (pc *platformConsole) mustRun(t *testing.T, verb platformVerb, args ...string) string {
+ t.Helper()
+ out, err := pc.run(t, verb, args...)
+ if err != nil {
+ t.Fatalf("%v: %v", args, err)
+ }
+ return out
+}
+
+const (
+ gib = int64(1) << 30
+ mib = int64(1) << 20
+)
+
+func platformCreated(day int) time.Time {
+ return time.Date(2026, time.November, day, 9, 30, 0, 0, time.UTC)
+}
+
+// The Task 1 mocks' three customers of platform bcd.
+func customerShop() platformCustomerView {
+ return platformCustomerView{Account: "bdf", Name: "shop", Ref: "4812", Plan: "free", PlanSource: "platform",
+ CreatedAt: platformCreated(19), Usage: []platformUsageView{
+ {Cap: "running_things", Used: 1, Limit: 2, Level: "ok"},
+ {Cap: "storage", Used: 40 * mib, Limit: gib, Level: "ok"},
+ }}
+}
+
+func customerBakery() platformCustomerView {
+ return platformCustomerView{Account: "bdg", Name: "bakery", Ref: "4813", Plan: "personal", PlanSource: "platform",
+ CreatedAt: platformCreated(19), Usage: []platformUsageView{
+ {Cap: "running_things", Used: 2, Limit: 10, Level: "ok"},
+ {Cap: "storage", Used: gib * 82 / 10, Limit: 10 * gib, Level: "warn"},
+ }}
+}
+
+func customerFlorist() platformCustomerView {
+ grace := time.Date(2026, time.September, 30, 0, 0, 0, 0, time.UTC)
+ return platformCustomerView{Account: "bdh", Name: "florist", Plan: "free", PlanSource: "platform",
+ CreatedAt: platformCreated(19), Usage: []platformUsageView{
+ {Cap: "running_things", Used: 3, Limit: 2, Level: "over", GraceEnds: &grace},
+ {Cap: "storage", Used: 120 * mib, Limit: gib, Level: "ok"},
+ }}
+}
+
+// noPlan is v as a console with no plan catalog shows it: no plan, no usage.
+func noPlan(v platformCustomerView) platformCustomerView {
+ v.Plan, v.PlanSource, v.Usage = "", "", []platformUsageView{}
+ return v
+}
+
+func TestPlatformCustomersCreateSendsAndPrints(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "POST /api/cli/platform/bcd/customers": {http.StatusCreated, platformCreateReply{Created: true, Customer: customerShop()}},
+ })
+ got := pc.mustRun(t, runPlatformCustomersCreateWithSession, "--platform", "bcd", "--name", "shop", "--ref", "4812")
+ if want := "created shop (bdf) on the free plan\n"; got != want {
+ t.Errorf("create printed %q, want the Task 1 mock %q", got, want)
+ }
+ if !reflect.DeepEqual(pc.reqs, []string{"POST /api/cli/platform/bcd/customers"}) {
+ t.Fatalf("requests %v", pc.reqs)
+ }
+ var body map[string]any
+ if err := json.Unmarshal([]byte(pc.bodies[0]), &body); err != nil {
+ t.Fatal(err)
+ }
+ if want := map[string]any{"name": "shop", "ref": "4812"}; !reflect.DeepEqual(body, want) {
+ t.Errorf("body %v, want %v", body, want)
+ }
+
+ // --plan goes with it; --json prints the door's reply.
+ pc.reqs, pc.bodies = nil, nil
+ got = pc.mustRun(t, runPlatformCustomersCreateWithSession, "--platform", "bcd", "--name", "shop", "--plan", "personal", "--json")
+ if !strings.Contains(pc.bodies[0], `"plan":"personal"`) {
+ t.Errorf("body %s lacks the plan", pc.bodies[0])
+ }
+ var reply platformCreateReply
+ if err := json.Unmarshal([]byte(got), &reply); err != nil || !reply.Created || reply.Customer.Account != "bdf" {
+ t.Errorf("--json printed %q (%v)", got, err)
+ }
+ if !strings.HasPrefix(got, "{\n \"") {
+ t.Errorf("--json is not indented: %q", got)
+ }
+}
+
+// TestPlatformCustomersCreateWithoutAPlan: on a console with no plan
+// catalog the new customer has no plan, so create says so with no plan
+// words (pre-flight C17).
+func TestPlatformCustomersCreateWithoutAPlan(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "POST /api/cli/platform/bcd/customers": {http.StatusCreated, platformCreateReply{Created: true, Customer: noPlan(customerShop())}},
+ })
+ got := pc.mustRun(t, runPlatformCustomersCreateWithSession, "--platform", "bcd", "--name", "shop", "--ref", "4812")
+ if want := fmt.Sprintf(cliPlatformCopyCreatedNoPlan+"\n", "shop", "bdf"); got != want || got != "created shop (bdf)\n" {
+ t.Errorf("create printed %q, want the no-catalog mock %q", got, want)
+ }
+}
+
+func TestPlatformCustomersCreateRefHitPrintsExisting(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "POST /api/cli/platform/bcd/customers": {http.StatusOK, platformCreateReply{Created: false, Customer: customerShop()}},
+ })
+ got := pc.mustRun(t, runPlatformCustomersCreateWithSession, "--platform", "bcd", "--name", "shop", "--ref", "4812")
+ if want := "shop (bdf) already exists for reference 4812\n"; got != want {
+ t.Errorf("ref hit printed %q, want %q", got, want)
+ }
+}
+
+func TestPlatformCustomersCreateRefusalIsTheConsoles(t *testing.T) {
+ refusal := "this platform has 50 customer accounts, the most its grant allows. ask the operator for more"
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "POST /api/cli/platform/bcd/customers": {http.StatusConflict, map[string]string{"error": refusal}},
+ })
+ if _, err := pc.run(t, runPlatformCustomersCreateWithSession, "--platform", "bcd", "--name", "shop"); err == nil || err.Error() != refusal {
+ t.Fatalf("err = %v, want the console's %q", err, refusal)
+ }
+}
+
+func TestPlatformCustomersListTable(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers": {http.StatusOK, platformCustomerList{Platform: "bcd", MaxCustomers: 50, Count: 3,
+ Customers: []platformCustomerView{customerShop(), customerBakery(), customerFlorist()}}},
+ })
+ got := pc.mustRun(t, runPlatformCustomersListWithSession, "--platform", "bcd")
+ want := `3 of 50 customer accounts, 1 over a limit, 1 near a limit
+ACCOUNT NAME REF PLAN CLAIMED USAGE
+bdf shop 4812 free no ok
+bdg bakery 4813 personal no near: object storage
+bdh florist - free no over: apps and instances
+`
+ if got != want {
+ t.Errorf("list:\n%s\nwant the Task 1 mock:\n%s", got, want)
+ }
+
+ // The heading names only the problems there are; the worst cap wins
+ // the USAGE word, and a ceiling is over.
+ shop, bakery := customerShop(), customerBakery()
+ bakery.Usage[0].Level = "ceiling"
+ bakery.Usage[0].Cap = "email"
+ shop.Claimed = true
+ pc.replies["GET /api/cli/platform/bcd/customers"] = platformDoorReply{http.StatusOK, platformCustomerList{
+ Platform: "bcd", MaxCustomers: 50, Count: 2, Customers: []platformCustomerView{shop, bakery}}}
+ got = pc.mustRun(t, runPlatformCustomersListWithSession, "--platform", "bcd")
+ want = `2 of 50 customer accounts, 1 over a limit
+ACCOUNT NAME REF PLAN CLAIMED USAGE
+bdf shop 4812 free yes ok
+bdg bakery 4813 personal no over: emails a day
+`
+ if got != want {
+ t.Errorf("list with one over:\n%s\nwant:\n%s", got, want)
+ }
+
+ bakery = customerBakery()
+ pc.replies["GET /api/cli/platform/bcd/customers"] = platformDoorReply{http.StatusOK, platformCustomerList{
+ Platform: "bcd", MaxCustomers: 50, Count: 2, Customers: []platformCustomerView{customerShop(), bakery}}}
+ if got = pc.mustRun(t, runPlatformCustomersListWithSession, "--platform", "bcd"); !strings.HasPrefix(got, "2 of 50 customer accounts, 1 near a limit\n") {
+ t.Errorf("list with one near starts %q", strings.SplitN(got, "\n", 2)[0])
+ }
+}
+
+// TestPlatformCustomersListWithoutPlans: with no plan catalog no customer
+// has a plan, so the list has no PLAN or USAGE column (the Task 1
+// no-catalog mock).
+func TestPlatformCustomersListWithoutPlans(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers": {http.StatusOK, platformCustomerList{Platform: "bcd", MaxCustomers: 50, Count: 3,
+ Customers: []platformCustomerView{noPlan(customerShop()), noPlan(customerBakery()), noPlan(customerFlorist())}}},
+ })
+ got := pc.mustRun(t, runPlatformCustomersListWithSession, "--platform", "bcd")
+ want := `3 of 50 customer accounts
+ACCOUNT NAME REF CLAIMED
+bdf shop 4812 no
+bdg bakery 4813 no
+bdh florist - no
+`
+ if got != want {
+ t.Errorf("list without plans:\n%s\nwant the Task 1 no-catalog mock:\n%s", got, want)
+ }
+}
+
+func TestPlatformCustomersListEmpty(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers": {http.StatusOK, platformCustomerList{Platform: "bcd", MaxCustomers: 50,
+ Customers: []platformCustomerView{}}},
+ })
+ got := pc.mustRun(t, runPlatformCustomersListWithSession, "--platform", "bcd")
+ if want := cliPlatformCopyListEmpty + "\n"; got != want {
+ t.Errorf("empty list printed %q, want %q", got, want)
+ }
+ got = pc.mustRun(t, runPlatformCustomersListWithSession, "--platform", "bcd", "--json")
+ var list platformCustomerList
+ if err := json.Unmarshal([]byte(got), &list); err != nil || list.MaxCustomers != 50 {
+ t.Errorf("--json printed %q (%v)", got, err)
+ }
+}
+
+// TestPlatformCustomersShowHeadings: the heading is the worst state of the
+// usage rows, and the rows put problems first (the Task 1 mocks).
+func TestPlatformCustomersShowHeadings(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers/bdf": {http.StatusOK, customerShop()},
+ "GET /api/cli/platform/bcd/customers/bdg": {http.StatusOK, customerBakery()},
+ "GET /api/cli/platform/bcd/customers/bdh": {http.StatusOK, customerFlorist()},
+ })
+ for _, tc := range []struct{ customer, want string }{
+ {"bdg", `bakery (bdg) is near a limit
+ plan personal
+ ref 4813
+ claimed no
+ created 19 November 2026
+usage
+ object storage 8.2 GB of 10 GB near the limit
+ apps and instances 2 of 10
+`},
+ {"bdh", `florist (bdh) is over a limit
+ plan free
+ claimed no
+ created 19 November 2026
+usage
+ apps and instances 3 of 2 over, grace until 30 September 2026
+ object storage 120 MB of 1 GB
+`},
+ {"bdf", `shop (bdf) is within its limits
+ plan free
+ ref 4812
+ claimed no
+ created 19 November 2026
+usage
+ apps and instances 1 of 2
+ object storage 40 MB of 1 GB
+`},
+ } {
+ got := pc.mustRun(t, runPlatformCustomersShowWithSession, "--platform", "bcd", "--customer", tc.customer)
+ if got != tc.want {
+ t.Errorf("show %s:\n%s\nwant the Task 1 mock:\n%s", tc.customer, got, tc.want)
+ }
+ }
+}
+
+// TestPlatformCustomersShowWithoutAPlan: a customer with no plan gets the
+// bare heading, no plan line and no usage section (the Task 1 no-catalog
+// mock).
+func TestPlatformCustomersShowWithoutAPlan(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers/bdf": {http.StatusOK, noPlan(customerShop())},
+ })
+ got := pc.mustRun(t, runPlatformCustomersShowWithSession, "--platform", "bcd", "--customer", "bdf")
+ want := `shop (bdf)
+ ref 4812
+ claimed no
+ created 19 November 2026
+`
+ if got != want {
+ t.Errorf("show without a plan:\n%s\nwant the Task 1 no-catalog mock:\n%s", got, want)
+ }
+}
+
+func TestPlatformCustomersRefLookup(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers?ref=4812": {http.StatusOK, platformCustomerList{Platform: "bcd", MaxCustomers: 50, Count: 3,
+ Customers: []platformCustomerView{customerShop()}}},
+ "GET /api/cli/platform/bcd/customers?ref=9999": {http.StatusOK, platformCustomerList{Platform: "bcd", MaxCustomers: 50, Count: 3,
+ Customers: []platformCustomerView{}}},
+ "GET /api/cli/platform/bcd/customers/bdf": {http.StatusOK, customerShop()},
+ })
+ got := pc.mustRun(t, runPlatformCustomersShowWithSession, "--platform", "bcd", "--ref", "4812")
+ if !strings.HasPrefix(got, "shop (bdf) is within its limits\n") {
+ t.Errorf("show --ref printed %q", got)
+ }
+ if want := []string{"GET /api/cli/platform/bcd/customers?ref=4812", "GET /api/cli/platform/bcd/customers/bdf"}; !reflect.DeepEqual(pc.reqs, want) {
+ t.Fatalf("requests %v, want %v", pc.reqs, want)
+ }
+
+ pc.reqs = nil
+ _, err := pc.run(t, runPlatformCustomersShowWithSession, "--platform", "bcd", "--ref", "9999")
+ if want := fmt.Sprintf(cliPlatformCopyNoRef, "9999"); err == nil || err.Error() != want {
+ t.Fatalf("unknown ref: err = %v, want %q", err, want)
+ }
+ if want := []string{"GET /api/cli/platform/bcd/customers?ref=9999"}; !reflect.DeepEqual(pc.reqs, want) {
+ t.Fatalf("unknown ref: requests %v, want %v", pc.reqs, want)
+ }
+
+ // A ref is escaped into the query.
+ pc.reqs = nil
+ pc.replies["GET /api/cli/platform/bcd/customers?ref=a%3Ab"] = pc.replies["GET /api/cli/platform/bcd/customers?ref=9999"]
+ pc.run(t, runPlatformCustomersShowWithSession, "--platform", "bcd", "--ref", "a:b")
+ if want := []string{"GET /api/cli/platform/bcd/customers?ref=a%3Ab"}; !reflect.DeepEqual(pc.reqs, want) {
+ t.Fatalf("escaped ref: requests %v, want %v", pc.reqs, want)
+ }
+}
+
+func TestPlatformCustomerFlagsNeedExactlyOneHandle(t *testing.T) {
+ pc := newPlatformConsole(t, nil)
+ for name, verb := range map[string]platformVerb{
+ "show": runPlatformCustomersShowWithSession,
+ "update": runPlatformCustomersUpdateWithSession,
+ "mint": runPlatformCredentialsMintWithSession,
+ } {
+ if _, err := pc.run(t, verb, "--platform", "bcd", "--customer", "bdf", "--ref", "4812"); err == nil || err.Error() != cliPlatformCopyOneHandle {
+ t.Errorf("%s with both: err = %v, want %q", name, err, cliPlatformCopyOneHandle)
+ }
+ if _, err := pc.run(t, verb, "--platform", "bcd"); err == nil || err.Error() != cliPlatformCopyNoHandle {
+ t.Errorf("%s with neither: err = %v, want %q", name, err, cliPlatformCopyNoHandle)
+ }
+ if _, err := pc.run(t, verb, "--platform", "bcd", "--customer", "BAD!"); err == nil ||
+ err.Error() != fmt.Sprintf(cliPlatformCopySqidInvalid, "--customer", "BAD!") {
+ t.Errorf("%s with a bad sqid: err = %v", name, err)
+ }
+ }
+ // Every verb needs --platform.
+ for name, verb := range map[string]platformVerb{
+ "create": runPlatformCustomersCreateWithSession,
+ "list": runPlatformCustomersListWithSession,
+ "show": runPlatformCustomersShowWithSession,
+ "update": runPlatformCustomersUpdateWithSession,
+ "mint": runPlatformCredentialsMintWithSession,
+ } {
+ if _, err := pc.run(t, verb); err == nil ||
+ err.Error() != fmt.Sprintf(cliPlatformCopySqidRequired, "--platform") {
+ t.Errorf("%s without --platform: err = %v", name, err)
+ }
+ }
+ if len(pc.reqs) != 0 {
+ t.Fatalf("a refused flag set sent %v", pc.reqs)
+ }
+}
+
+func TestPlatformCustomersUpdateSendsAndPrints(t *testing.T) {
+ renamed := customerShop()
+ renamed.Name, renamed.Plan = "corner-shop", "personal"
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers/bdf": {http.StatusOK, customerShop()},
+ "PATCH /api/cli/platform/bcd/customers/bdf": {http.StatusOK, renamed},
+ })
+ got := pc.mustRun(t, runPlatformCustomersUpdateWithSession, "--platform", "bcd", "--customer", "bdf",
+ "--name", "corner-shop", "--plan", "personal", "--reason", "upgraded")
+ want := "shop (bdf) is now called corner-shop\ncorner-shop (bdf) is now on the personal plan\n"
+ if got != want {
+ t.Errorf("update printed %q, want %q", got, want)
+ }
+ if want := []string{"GET /api/cli/platform/bcd/customers/bdf", "PATCH /api/cli/platform/bcd/customers/bdf"}; !reflect.DeepEqual(pc.reqs, want) {
+ t.Fatalf("requests %v, want %v", pc.reqs, want)
+ }
+ var body map[string]any
+ if err := json.Unmarshal([]byte(pc.bodies[1]), &body); err != nil {
+ t.Fatal(err)
+ }
+ if want := map[string]any{"name": "corner-shop", "plan": "personal", "reason": "upgraded"}; !reflect.DeepEqual(body, want) {
+ t.Errorf("body %v, want %v", body, want)
+ }
+
+ // --ref resolves through the lookup, which already names the customer.
+ pc.reqs, pc.bodies = nil, nil
+ pc.replies["GET /api/cli/platform/bcd/customers?ref=4812"] = platformDoorReply{http.StatusOK, platformCustomerList{
+ Platform: "bcd", MaxCustomers: 50, Count: 1, Customers: []platformCustomerView{customerShop()}}}
+ got = pc.mustRun(t, runPlatformCustomersUpdateWithSession, "--platform", "bcd", "--ref", "4812", "--plan", "personal")
+ if want := "corner-shop (bdf) is now on the personal plan\n"; got != want {
+ t.Errorf("update --plan printed %q, want %q", got, want)
+ }
+ if want := []string{"GET /api/cli/platform/bcd/customers?ref=4812", "PATCH /api/cli/platform/bcd/customers/bdf"}; !reflect.DeepEqual(pc.reqs, want) {
+ t.Fatalf("requests %v, want %v", pc.reqs, want)
+ }
+ if want := `{"plan":"personal"}`; strings.TrimSpace(pc.bodies[1]) != want {
+ t.Errorf("body %s, want %s", pc.bodies[1], want)
+ }
+}
+
+// mintReply is the fake console's credential: the customer's account and
+// name ride on the reply (pre-flight C5).
+func mintReply() platformCredentialReply {
+ return platformCredentialReply{Token: "carlos_svc_0123456789", Account: "bdf", Name: "shop", Role: "publish",
+ ExpiresAt: time.Date(2026, time.November, 19, 15, 4, 0, 0, time.UTC)}
+}
+
+func TestPlatformCredentialsMintJSON(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "POST /api/cli/platform/bcd/customers/bdf/credentials": {http.StatusCreated, mintReply()},
+ })
+ got := pc.mustRun(t, runPlatformCredentialsMintWithSession, "--platform", "bcd", "--customer", "bdf", "--json")
+ var reply platformCredentialReply
+ if err := json.Unmarshal([]byte(got), &reply); err != nil {
+ t.Fatalf("--json printed %q: %v", got, err)
+ }
+ if want := mintReply(); reply.Token != want.Token || reply.Name != "shop" || reply.Account != "bdf" || !reply.ExpiresAt.Equal(want.ExpiresAt) {
+ t.Errorf("--json reply %+v, want the fake's %+v", reply, want)
+ }
+ if !strings.HasPrefix(got, "{\n \"") {
+ t.Errorf("--json is not indented: %q", got)
+ }
+}
+
+func TestPlatformCredentialsMintPrints(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "POST /api/cli/platform/bcd/customers/bdf/credentials": {http.StatusCreated, mintReply()},
+ })
+ got := pc.mustRun(t, runPlatformCredentialsMintWithSession, "--platform", "bcd", "--customer", "bdf")
+ want := `minted a publish credential for shop (bdf)
+ valid until 19 November 2026 15:04 UTC
+ token carlos_svc_0123456789
+use it as CARLOS_SERVICE_TOKEN with --account bdf
+`
+ if got != want {
+ t.Errorf("mint:\n%s\nwant the Task 1 mock:\n%s", got, want)
+ }
+ var body map[string]any
+ if err := json.Unmarshal([]byte(pc.bodies[0]), &body); err != nil {
+ t.Fatal(err)
+ }
+ if want := map[string]any{"role": "publish", "ttl_seconds": float64(3600)}; !reflect.DeepEqual(body, want) {
+ t.Errorf("default body %v, want %v", body, want)
+ }
+}
+
+func TestPlatformCredentialsMintSendsTTL(t *testing.T) {
+ pc := newPlatformConsole(t, map[string]platformDoorReply{
+ "GET /api/cli/platform/bcd/customers?ref=4812": {http.StatusOK, platformCustomerList{Platform: "bcd", MaxCustomers: 50, Count: 1,
+ Customers: []platformCustomerView{customerShop()}}},
+ "POST /api/cli/platform/bcd/customers/bdf/credentials": {http.StatusCreated, mintReply()},
+ })
+ pc.mustRun(t, runPlatformCredentialsMintWithSession, "--platform", "bcd", "--ref", "4812",
+ "--role", "deploy", "--app", "site", "--rungs", "dev, prod", "--ttl", "2h")
+ if want := []string{"GET /api/cli/platform/bcd/customers?ref=4812", "POST /api/cli/platform/bcd/customers/bdf/credentials"}; !reflect.DeepEqual(pc.reqs, want) {
+ t.Fatalf("requests %v, want %v", pc.reqs, want)
+ }
+ var body map[string]any
+ if err := json.Unmarshal([]byte(pc.bodies[1]), &body); err != nil {
+ t.Fatal(err)
+ }
+ want := map[string]any{"role": "deploy", "app": "site", "rungs": []any{"dev", "prod"}, "ttl_seconds": float64(7200)}
+ if !reflect.DeepEqual(body, want) {
+ t.Errorf("body %v, want %v", body, want)
+ }
+}
+
+// TestPlatformCredentialsMintNeverSendsZeroTTL: the door reads 0 as its
+// default hour, so a --ttl that is 0, negative or under a second must not
+// arrive as 0.
+func TestPlatformCredentialsMintNeverSendsZeroTTL(t *testing.T) {
+ for _, tc := range []struct {
+ ttl string
+ want int64
+ }{{"0", -1}, {"-5m", -1}, {"500ms", 1}, {"90s", 90}, {"24h", 86400}} {
+ if got := platformTTLSeconds(mustDuration(t, tc.ttl)); got != tc.want {
+ t.Errorf("--ttl %s sends %d, want %d", tc.ttl, got, tc.want)
+ }
+ }
+}
+
+func mustDuration(t *testing.T, s string) time.Duration {
+ t.Helper()
+ d, err := time.ParseDuration(s)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return d
+}
+
+// TestPlatformCommandsNeedAConsole: in direct bucket mode every verb is
+// refused with the platform refusal naming it, and -h is not an error.
+func TestPlatformCommandsNeedAConsole(t *testing.T) {
+ t.Setenv("CARLOS_DEPLOYMENT_DIR", t.TempDir())
+ t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "")
+ t.Setenv("CARLOS_SERVICE_TOKEN", "")
+ for _, tc := range []struct {
+ command string
+ verb platformVerb
+ run func([]string) error
+ args []string
+ }{
+ {"platform customers create", runPlatformCustomersCreateWithSession, runPlatformCustomersCreate, []string{"--name", "shop"}},
+ {"platform customers list", runPlatformCustomersListWithSession, runPlatformCustomersList, nil},
+ {"platform customers show", runPlatformCustomersShowWithSession, runPlatformCustomersShow, []string{"--customer", "bdf"}},
+ {"platform customers update", runPlatformCustomersUpdateWithSession, runPlatformCustomersUpdate, []string{"--ref", "4812", "--plan", "free"}},
+ {"platform credentials mint", runPlatformCredentialsMintWithSession, runPlatformCredentialsMint, []string{"--customer", "bdf"}},
+ } {
+ err := tc.verb(context.Background(), nil, append([]string{"--platform", "bcd"}, tc.args...), io.Discard)
+ if want := fmt.Sprintf(cliPlatformCopyNeedsConsole, tc.command); err == nil || err.Error() != want {
+ t.Errorf("%s: err = %v, want %q", tc.command, err, want)
+ }
+ if err := tc.run([]string{"-h"}); err != nil {
+ t.Errorf("%s -h = %v, want nil (usage is not an error)", tc.command, err)
+ }
+ }
+}
+
+// TestPlatformCommandsWorkWithAServiceToken: CARLOS_SERVICE_TOKEN with
+// CARLOS_CONSOLE is a session with no login, the platform's own servers'
+// way in.
+func TestPlatformCommandsWorkWithAServiceToken(t *testing.T) {
+ var auth string
+ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ auth = r.Header.Get("Authorization")
+ json.NewEncoder(w).Encode(platformCustomerList{Platform: "bcd", MaxCustomers: 50, Customers: []platformCustomerView{}})
+ }))
+ t.Cleanup(ts.Close)
+ t.Setenv("CARLOS_DEPLOYMENT_DIR", "")
+ t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "")
+ t.Setenv("CARLOS_SERVICE_TOKEN", "carlos_svc_platform")
+ t.Setenv("CARLOS_CONSOLE", ts.URL)
+ var out bytes.Buffer
+ if err := runPlatformCustomersListWithSession(context.Background(), nil, []string{"--platform", "bcd", "--json"}, &out); err != nil {
+ t.Fatal(err)
+ }
+ if auth != "Bearer carlos_svc_platform" {
+ t.Errorf("Authorization %q, want the service token", auth)
+ }
+ if !strings.HasPrefix(out.String(), "{") {
+ t.Errorf("--json output starts %q: no banner goes before the JSON", out.String())
+ }
+}
diff --git a/platform_copy.go b/platform_copy.go
index 664c270a3..d562ed926 100644
--- a/platform_copy.go
+++ b/platform_copy.go
@@ -51,4 +51,72 @@ const (
cliPlatformCopyGranted = "%s is now a platform account"
cliPlatformCopyRevoked = "turned off platform access for %s. credentials that stopped working: %d"
+
+ // `carlos platform customers` and `carlos platform credentials` (Task
+ // 11).
+ cliPlatformCopyFlagPlatform = "your platform account’s sqid"
+ cliPlatformCopyFlagCustomer = "the customer account’s sqid"
+ cliPlatformCopyFlagRef = "your own id for the customer, instead of --customer"
+ cliPlatformCopyFlagName = "the customer account’s name"
+ cliPlatformCopyFlagPlan = "plan to put the account on"
+ cliPlatformCopyFlagRole = "publish (the whole account) or deploy (one app)"
+ cliPlatformCopyFlagApp = "the app a deploy credential is for"
+ cliPlatformCopyFlagRungs = "the rungs a deploy credential may move, comma-separated"
+ cliPlatformCopyFlagTTL = "how long the credential works, 1m to 24h"
+ cliPlatformCopyFlagJSON = "print JSON for scripts"
+ // FlagCreateRef is --ref on create, where it also makes a retry safe:
+ // create is idempotent only on the ref (a row Task 11 adds).
+ cliPlatformCopyFlagCreateRef = "your own id for the customer. pass it so a retried create returns the same account"
+ // CreateRetry closes `carlos platform`'s usage (a row Task 11 adds).
+ cliPlatformCopyCreateRetry = "a create retried without --ref can make a second account.\npass --ref so a retried create returns the same account"
+ // SqidRequired and SqidInvalid refuse --platform or --customer before
+ // anything is sent; %s is the flag (rows Task 11 adds, worded as
+ // --account's existing refusals).
+ cliPlatformCopySqidRequired = "%s requires an account sqid"
+ cliPlatformCopySqidInvalid = "%s %q is not an account sqid"
+
+ cliPlatformCopyOneHandle = "pass --customer or --ref, not both"
+ cliPlatformCopyNoHandle = "pass --customer or --ref"
+ cliPlatformCopyNoRef = "no customer account has the reference %s"
+
+ cliPlatformCopyListHeading = "%d of %d customer accounts"
+ cliPlatformCopyListOver = ", %d over a limit"
+ cliPlatformCopyListNear = ", %d near a limit"
+ cliPlatformCopyListEmpty = "no customer accounts yet. create one with carlos platform customers create"
+ cliPlatformCopyColAccount = "ACCOUNT"
+ cliPlatformCopyColName = "NAME"
+ cliPlatformCopyColRef = "REF"
+ cliPlatformCopyColPlan = "PLAN"
+ cliPlatformCopyColOwned = "CLAIMED"
+ cliPlatformCopyColUsage = "USAGE"
+ cliPlatformCopyYes = "yes"
+ cliPlatformCopyNo = "no"
+ cliPlatformCopyUsageOK = "ok"
+ cliPlatformCopyUsageNear = "near: %s"
+ cliPlatformCopyUsageOver = "over: %s"
+
+ cliPlatformCopyShowHeading = "%s (%s)"
+ cliPlatformCopyShowOK = "%s (%s) is within its limits"
+ cliPlatformCopyShowNear = "%s (%s) is near a limit"
+ cliPlatformCopyShowOver = "%s (%s) is over a limit"
+ cliPlatformCopyLabelRef = "ref"
+ cliPlatformCopyLabelPlan = "plan"
+ cliPlatformCopyLabelOwned = "claimed"
+ cliPlatformCopyLabelCreated = "created"
+ cliPlatformCopyUsageHeading = "usage"
+ cliPlatformCopyUsageRow = "%s of %s"
+ cliPlatformCopyUsageNearLimit = "near the limit"
+ cliPlatformCopyUsageOverLimit = "over, grace until %s"
+ cliPlatformCopyCapPDF = "PDFs a month"
+
+ cliPlatformCopyCreated = "created %s (%s) on the %s plan"
+ cliPlatformCopyCreatedNoPlan = "created %s (%s)"
+ cliPlatformCopyExists = "%s (%s) already exists for reference %s"
+ cliPlatformCopyRenamed = "%s (%s) is now called %s"
+ cliPlatformCopyReplanned = "%s (%s) is now on the %s plan"
+
+ cliPlatformCopyMinted = "minted a %s credential for %s (%s)"
+ cliPlatformCopyLabelValidUntil = "valid until"
+ cliPlatformCopyMintedToken = "token"
+ cliPlatformCopyMintedUse = "use it as CARLOS_SERVICE_TOKEN with --account %s"
)
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl
index 7b83423df..99b730bb0 100644
--- a/testdata/clireg-golden.jsonl
+++ b/testdata/clireg-golden.jsonl
@@ -607,6 +607,34 @@
{"case":"pipeline | bare","argv":["pipeline"],"exit":1,"stdout":"","stderr":"no deployment target configured: set CARLOS_DEPLOYMENT_BUCKET (or CARLOS_DEPLOYMENT_DIR) for direct bucket access, or run carlos auth login --console <url> to work through a console\n"}
{"case":"pipeline | help","argv":["pipeline","help"],"exit":1,"stdout":"","stderr":"usage: carlos pipeline <command>\n\ncommands:\n show show an app's channels and any pending changes\n (this is also what a bare \"carlos pipeline\"\n runs)\n init --template edge-production|full-ladder\n replace the pipeline with a starter template\n set --channel <name> [--bake <dur>] [--passkey[=false]]\n [--promote-approvals N] [--change-approvals N]\n edit one existing channel's bake window or\n rules — flags not given are left as they were\n add --channel <name> [--after <name>] [--bake <dur>] [--passkey]\n [--promote-approvals N] [--change-approvals N]\n insert a new channel (default: appended at the\n end of the list; --after inserts right after\n that existing channel)\n remove --channel <name> drop a channel from the pipeline\n\nEvery command above also takes [--app <a>] [--account <sqid-or-name>]\n[--account-id <sqid>] [--console <origin>] — the same account/app resolution\nevery other API-mode verb uses (defaults apply when a flag is omitted and\nonly one candidate exists).\n\ncarlos pipeline works through a logged-in console (carlos auth login) —\nthere is no bucket-direct pipeline editor to fall back to; --bake, --passkey,\n--promote-approvals and --change-approvals set release.ChannelRules exactly as\nthe console's own pipeline settings page does. promote and rollback are\nunaffected in direct mode.\n\nset/add/remove all read the CURRENT channel list first and PUT the whole\nlist back — an edit that touches a channel the stored pipeline already\nguards with --change-approvals does not land from here: the console turns it\ninto a proposal instead (0 confirmations; finish with the printed console\nURL), exactly as it does for a guarded promote or rollback.\n"}
{"case":"pipeline | zz-unknown","argv":["pipeline","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos pipeline <command>\n\ncommands:\n show show an app's channels and any pending changes\n (this is also what a bare \"carlos pipeline\"\n runs)\n init --template edge-production|full-ladder\n replace the pipeline with a starter template\n set --channel <name> [--bake <dur>] [--passkey[=false]]\n [--promote-approvals N] [--change-approvals N]\n edit one existing channel's bake window or\n rules — flags not given are left as they were\n add --channel <name> [--after <name>] [--bake <dur>] [--passkey]\n [--promote-approvals N] [--change-approvals N]\n insert a new channel (default: appended at the\n end of the list; --after inserts right after\n that existing channel)\n remove --channel <name> drop a channel from the pipeline\n\nEvery command above also takes [--app <a>] [--account <sqid-or-name>]\n[--account-id <sqid>] [--console <origin>] — the same account/app resolution\nevery other API-mode verb uses (defaults apply when a flag is omitted and\nonly one candidate exists).\n\ncarlos pipeline works through a logged-in console (carlos auth login) —\nthere is no bucket-direct pipeline editor to fall back to; --bake, --passkey,\n--promote-approvals and --change-approvals set release.ChannelRules exactly as\nthe console's own pipeline settings page does. promote and rollback are\nunaffected in direct mode.\n\nset/add/remove all read the CURRENT channel list first and PUT the whole\nlist back — an edit that touches a channel the stored pipeline already\nguards with --change-approvals does not land from here: the console turns it\ninto a proposal instead (0 confirmations; finish with the printed console\nURL), exactly as it does for a guarded promote or rollback.\n"}
+{"case":"platform credentials mint | --zz-unknown-flag","argv":["platform","credentials","mint","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos platform credentials mint [flags]\nflags:\n --app <string> the app a deploy credential is for\n --console <string> console origin to use\n --customer <string> the customer account’s sqid\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --platform <string> your platform account’s sqid\n --ref <string> your own id for the customer, instead of --customer\n --role <string> publish (the whole account) or deploy (one app) (default: publish)\n --rungs <string> the rungs a deploy credential may move, comma-separated\n --ttl <duration> how long the credential works, 1m to 24h (default: 1h0m0s)\n","stderr":"platform credentials mint: flag provided but not defined: -zz-unknown-flag\n"}
+{"case":"platform credentials mint | -h","argv":["platform","credentials","mint","-h"],"exit":0,"stdout":"usage: carlos platform credentials mint [flags]\nflags:\n --app <string> the app a deploy credential is for\n --console <string> console origin to use\n --customer <string> the customer account’s sqid\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --platform <string> your platform account’s sqid\n --ref <string> your own id for the customer, instead of --customer\n --role <string> publish (the whole account) or deploy (one app) (default: publish)\n --rungs <string> the rungs a deploy credential may move, comma-separated\n --ttl <duration> how long the credential works, 1m to 24h (default: 1h0m0s)\n","stderr":""}
+{"case":"platform credentials | --help","argv":["platform","credentials","--help"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform credentials | --zz-unknown-flag","argv":["platform","credentials","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform credentials | -h","argv":["platform","credentials","-h"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform credentials | bare","argv":["platform","credentials"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform credentials | help","argv":["platform","credentials","help"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform credentials | zz-unknown","argv":["platform","credentials","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform customers create | --zz-unknown-flag","argv":["platform","customers","create","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos platform customers create [flags]\nflags:\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --name <string> the customer account’s name\n --plan <string> plan to put the account on\n --platform <string> your platform account’s sqid\n --ref <string> your own id for the customer. pass it so a retried create returns the same account\n","stderr":"platform customers create: flag provided but not defined: -zz-unknown-flag\n"}
+{"case":"platform customers create | -h","argv":["platform","customers","create","-h"],"exit":0,"stdout":"usage: carlos platform customers create [flags]\nflags:\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --name <string> the customer account’s name\n --plan <string> plan to put the account on\n --platform <string> your platform account’s sqid\n --ref <string> your own id for the customer. pass it so a retried create returns the same account\n","stderr":""}
+{"case":"platform customers list | --zz-unknown-flag","argv":["platform","customers","list","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos platform customers list [flags]\nflags:\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --platform <string> your platform account’s sqid\n","stderr":"platform customers list: flag provided but not defined: -zz-unknown-flag\n"}
+{"case":"platform customers list | -h","argv":["platform","customers","list","-h"],"exit":0,"stdout":"usage: carlos platform customers list [flags]\nflags:\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --platform <string> your platform account’s sqid\n","stderr":""}
+{"case":"platform customers show | --zz-unknown-flag","argv":["platform","customers","show","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos platform customers show [flags]\nflags:\n --console <string> console origin to use\n --customer <string> the customer account’s sqid\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --platform <string> your platform account’s sqid\n --ref <string> your own id for the customer, instead of --customer\n","stderr":"platform customers show: flag provided but not defined: -zz-unknown-flag\n"}
+{"case":"platform customers show | -h","argv":["platform","customers","show","-h"],"exit":0,"stdout":"usage: carlos platform customers show [flags]\nflags:\n --console <string> console origin to use\n --customer <string> the customer account’s sqid\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --json print JSON for scripts\n --platform <string> your platform account’s sqid\n --ref <string> your own id for the customer, instead of --customer\n","stderr":""}
+{"case":"platform customers update | --zz-unknown-flag","argv":["platform","customers","update","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos platform customers update [flags]\nflags:\n --console <string> console origin to use\n --customer <string> the customer account’s sqid\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --name <string> the customer account’s name\n --plan <string> plan to put the account on\n --platform <string> your platform account’s sqid\n --reason <string> why. it is kept with the change\n --ref <string> your own id for the customer, instead of --customer\n","stderr":"platform customers update: flag provided but not defined: -zz-unknown-flag\n"}
+{"case":"platform customers update | -h","argv":["platform","customers","update","-h"],"exit":0,"stdout":"usage: carlos platform customers update [flags]\nflags:\n --console <string> console origin to use\n --customer <string> the customer account’s sqid\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --name <string> the customer account’s name\n --plan <string> plan to put the account on\n --platform <string> your platform account’s sqid\n --reason <string> why. it is kept with the change\n --ref <string> your own id for the customer, instead of --customer\n","stderr":""}
+{"case":"platform customers | --help","argv":["platform","customers","--help"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform customers | --zz-unknown-flag","argv":["platform","customers","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform customers | -h","argv":["platform","customers","-h"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform customers | bare","argv":["platform","customers"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform customers | help","argv":["platform","customers","help"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform customers | zz-unknown","argv":["platform","customers","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform | --help","argv":["platform","--help"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform | --zz-unknown-flag","argv":["platform","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform | -h","argv":["platform","-h"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform | bare","argv":["platform"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform | help","argv":["platform","help"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
+{"case":"platform | zz-unknown","argv":["platform","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos platform customers <create|list|show|update> --platform <sqid>\n carlos platform credentials mint --platform <sqid>\n\n customers create --name <name> [--ref <ref>] [--plan <plan>] [--json]\n customers list [--json]\n customers show (--customer <sqid> | --ref <ref>) [--json]\n customers update (--customer <sqid> | --ref <ref>)\n [--name <name>] [--plan <plan>] [--reason <text>]\n credentials mint (--customer <sqid> | --ref <ref>) [--role publish|deploy]\n [--app <app>] [--rungs <a,b>] [--ttl <duration>] [--json]\n\na create retried without --ref can make a second account.\npass --ref so a retried create returns the same account\n"}
{"case":"promote | --zz-unknown-flag","argv":["promote","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos promote [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to promote through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --hotfix bypass the channel ladder (recorded as a hotfix)\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --retry re-sign the channel's current promotion of this version with a fresh time, so a box that refused it tries again\n"}
{"case":"promote | -h","argv":["promote","-h"],"exit":0,"stdout":"","stderr":"usage: carlos promote [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --console <string> console origin to promote through (API mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --hotfix bypass the channel ladder (recorded as a hotfix)\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --retry re-sign the channel's current promotion of this version with a fresh time, so a box that refused it tries again\n"}
{"case":"proof get | --zz-unknown-flag","argv":["proof","get","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos proof get [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --app, -a <string> app name\n --prover <string> whose proof (default: the only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n --sha256 <string> the artifact's sha256, hex\n"}