feat(tpagectl): implement version command #581

Merged
fuzzy merged 2 commits from feat/cli-version into main 2026-08-07 06:36:24 +00:00
Owner

What

Implements the version command, the second Phase 5 operational command.

  • New internal/tpagectl/version package with a top-level version command registered on the root (coexisting with the existing --version flag).
  • #240: prints the CLI version, commit, and build date injected at build time via -ldflagsNewCommand(version, commit, date string) takes the metadata from main (where the build vars live), with output matching the --version flag format (tpagectl version <v> / commit: <c> / built: <d>).
  • Tests: injected values render; root help lists version; version --help renders; end-to-end output contains version/commit/built.

Why

Phase 5 roadmap task #242.

Testing

  • version package output test (injected version/commit/date)
  • Wiring: root help lists version, version --help renders, version output
  • go test -race ./... passes (21 packages)
  • golangci-lint run clean
  • pre-commit hooks pass (gofmt, go mod tidy, go test)

Breaking Changes

None.

Notes

#241 (optionally check the latest available version on the server) is deferred — the daemon exposes no version endpoint (/healthz//readyz only return status). It remains unchecked in CLI-ROADMAP.md.

Closes #240
Closes #242

## What Implements the `version` command, the second Phase 5 operational command. - New `internal/tpagectl/version` package with a top-level `version` command registered on the root (coexisting with the existing `--version` flag). - **#240**: prints the CLI version, commit, and build date injected at build time via `-ldflags` — `NewCommand(version, commit, date string)` takes the metadata from main (where the build vars live), with output matching the `--version` flag format (`tpagectl version <v>` / `commit: <c>` / `built: <d>`). - Tests: injected values render; root help lists `version`; `version --help` renders; end-to-end output contains version/commit/built. ## Why Phase 5 roadmap task #242. ## Testing - [x] `version` package output test (injected version/commit/date) - [x] Wiring: root help lists `version`, `version --help` renders, `version` output - [x] `go test -race ./...` passes (21 packages) - [x] `golangci-lint run` clean - [x] pre-commit hooks pass (gofmt, go mod tidy, go test) ## Breaking Changes None. ## Notes #241 (optionally check the latest available version on the server) is deferred — the daemon exposes no version endpoint (`/healthz`/`/readyz` only return status). It remains unchecked in CLI-ROADMAP.md. Closes #240 Closes #242
Add the tpagectl version command, which prints the CLI version, commit,
and build date injected at build time via -ldflags. The build metadata is
passed into the command from main, matching the existing --version flag
output format.
docs(roadmap): mark version command complete
All checks were successful
Test and Release / lint (pull_request) Successful in 4m59s
Test and Release / test (pull_request) Successful in 23m57s
a3d6b6d194
Record completion of the tpagectl version command: CLI version and build
date display. Checking the latest available server version (#241) is
deferred - the daemon exposes no version endpoint.

closes #240
closes #242
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-07 06:22:34 +00:00
the.auditor left a comment

Summary

version command for tpagectl, second Phase 5 operational command. Verified: go test -race ./... passes (21 packages, including new internal/tpagectl/version) and golangci-lint run ./... is clean. Closes #240/#242; #241 (server version check) honestly deferred and left unchecked.

Verified: output format matches the --version flag's VersionPrinter exactly; the import alias tpagectlversion correctly avoids the version variable collision in main.go; NewCommand(version, commit, date) cleanly receives build metadata.

No blocking issues.

Suggestions (filed as issues)

  1. cmd/tpagectl/main.go + internal/tpagectl/version/version.gotpagectl version runs the root Before hook, which loads config and builds the HTTP client; an invalid --server URL or broken config would make version fail even though it never talks to the daemon. Filed as #582

Minor Note (no issue)

  • The version output duplicates the --version VersionPrinter format (three Fprintf lines); a shared helper would remove the duplication (extends the #565 DRY theme).

Praise

  • Output format consistent with the existing --version flag
  • Correct alias handling for the version build var collision
  • Honest #241 deferral left unchecked in the roadmap
  • Clean tests: injected values, root help, --help, and end-to-end output
## Summary `version` command for tpagectl, second Phase 5 operational command. Verified: `go test -race ./...` passes (21 packages, including new `internal/tpagectl/version`) and `golangci-lint run ./...` is clean. Closes #240/#242; #241 (server version check) honestly deferred and left unchecked. Verified: output format matches the `--version` flag's `VersionPrinter` exactly; the import alias `tpagectlversion` correctly avoids the `version` variable collision in `main.go`; `NewCommand(version, commit, date)` cleanly receives build metadata. No blocking issues. ## Suggestions (filed as issues) 1. `cmd/tpagectl/main.go` + `internal/tpagectl/version/version.go` – `tpagectl version` runs the root `Before` hook, which loads config and builds the HTTP client; an invalid `--server` URL or broken config would make `version` fail even though it never talks to the daemon. Filed as #582 ## Minor Note (no issue) - The version output duplicates the `--version` `VersionPrinter` format (three `Fprintf` lines); a shared helper would remove the duplication (extends the #565 DRY theme). ## Praise - Output format consistent with the existing `--version` flag - Correct alias handling for the `version` build var collision - Honest #241 deferral left unchecked in the roadmap - Clean tests: injected values, root help, `--help`, and end-to-end output
fuzzy merged commit a3d6b6d194 into main 2026-08-07 06:36:24 +00:00
fuzzy deleted branch feat/cli-version 2026-08-07 06:36:24 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd!581
No description provided.