feat(tpagectl): add command examples #610
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!610
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tpagectl-command-examples"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implements Phase 8 command examples (roadmap #283).
internal/tpagectl/examples— a pointer-keyed registry of usage examples per command.Apply(cmd, text)adds an--examplesflag and wraps the command's Action so--examplesprints the examples and returns successfully without running the command (works offline). Keying by command pointer avoids collisions between same-named subcommands (get/list/deleteacross groups).--examplesflag (#281) — added to all 18 leaf commands (site create/list/get/delete/update, deployment list/get/promote/rollback, preview list/deploy/delete/get, status, version, login, token set/clear), each with 2–4 realistic usage lines.newCommandinstalls a customcli.HelpPrinterthat appends anEXAMPLESsection to--helpoutput (and thehelpsubcommand) for registered commands.docs/commands/*.mdanddocs/man/*.1now list the--examplesflag and include an Examples section.Why
Roadmap task #283.
Testing
examplesunit tests:--examplesprints and short-circuits (underlying Action not run); without--examplesthe Action runs;Lookup/Flag; missing examples errorsite create --examplesprints examples with no error;site create --helpincludes the EXAMPLES section and example textgo test -race ./...passes (30 packages)golangci-lint runcleanBreaking Changes
None.
--examplesis additive;--helpgains an EXAMPLES section.Notes
urfave/cli v3 has no
Examplesfield, so the registry is keyed by*cli.Commandpointer; thedocsgenerator reads it to include Examples in the generated Markdown/man pages.Closes #281
Closes #282
Closes #283
Clean examples system. The pointer-keyed registry neatly avoids collisions between same-named subcommands (
get/list/delete),--examplesshort-circuits before the wrapped Action (so it wins over validation, e.g.token set --examples), the customHelpPrinterappends an EXAMPLES section without disturbing existing help, and the docs generator picks up examples + the--examplesflag (verified in regenerateddocs/commands/tpagectl-site-create.md).versionis included. Approving; one behavioral gap filed.Suggestions
internal/tpagectl/examples/examples.go:32–--examplesshort-circuits inside the Action, but the rootBeforehook (config load,newClient→ keychain token resolve, TLS config) runs first. With a malformed config, a genuine keychain error, or a broken--ca-cert,--examplesfails instead of printing — the "works offline" claim doesn't fully hold. Consider short-circuiting before client construction in the rootBefore. Filed as #611.Notes
## Subcommandsheader from #609 (separate issue, not this PR's scope).cli.HelpPrinteris a package-global override set innewCommand(); safe for a single binary.Praise
Applypreserves the original Action and mutates in place, keeping the wiring trivial and uniform across all 18 leaf commands.