feat(cli): scaffold tpagectl command #535

Merged
fuzzy merged 3 commits from feature/cli-scaffold into main 2026-08-05 00:04:56 +00:00
Owner

What

Initializes the tpagectl CLI module structure: a new cmd/tpagectl/ entrypoint backed by the urfave/cli v3 framework, reusing the existing thwap-pagesd Go module, plus build-time version metadata wired through the Makefile.

Why

First task in CLI-ROADMAP.md Phase 1 (Project Setup and CLI Framework). Lays the foundation for the site, deployment, and preview command groups that follow.

Testing

  • Unit tests pass (go test -race ./...)
  • go vet ./..., golangci-lint run, go mod verify clean
  • make build-tpagectl produces a working binary; --version prints build metadata
  • New tests added: cmd/tpagectl/main_test.go (root command wiring + --version output)

Breaking Changes

None.

Screenshots

$ ./dist/tpagectl --version
tpagectl version dev
commit: 5b78086
built: 2026-08-04T22:38:49Z

Notes

  • Framework choice: urfave/cli v3 (per decision; roadmap allowed cobra-cli or urfave/cli).
  • Module decision (#146): reuse existing git.lan.thwap.org/thwap/thwap-pagesd module; CLI and daemon share errors/, logging/, and vendored deps.
  • Version command with server-side latest-check remains Phase 5 (#242).
  • Milestone: Phase 1: Project Setup and CLI Framework.

Closes #145
Closes #146
Closes #147
Closes #148
Closes #149

## What Initializes the `tpagectl` CLI module structure: a new `cmd/tpagectl/` entrypoint backed by the urfave/cli v3 framework, reusing the existing `thwap-pagesd` Go module, plus build-time version metadata wired through the Makefile. ## Why First task in [CLI-ROADMAP.md](CLI-ROADMAP.md) Phase 1 (Project Setup and CLI Framework). Lays the foundation for the site, deployment, and preview command groups that follow. ## Testing - [x] Unit tests pass (`go test -race ./...`) - [x] `go vet ./...`, `golangci-lint run`, `go mod verify` clean - [x] `make build-tpagectl` produces a working binary; `--version` prints build metadata - [x] New tests added: `cmd/tpagectl/main_test.go` (root command wiring + `--version` output) ## Breaking Changes None. ## Screenshots ``` $ ./dist/tpagectl --version tpagectl version dev commit: 5b78086 built: 2026-08-04T22:38:49Z ``` ## Notes - Framework choice: urfave/cli v3 (per decision; roadmap allowed cobra-cli or urfave/cli). - Module decision (#146): reuse existing `git.lan.thwap.org/thwap/thwap-pagesd` module; CLI and daemon share `errors/`, `logging/`, and vendored deps. - Version command with server-side latest-check remains Phase 5 (#242). - Milestone: Phase 1: Project Setup and CLI Framework. Closes #145 Closes #146 Closes #147 Closes #148 Closes #149
Create cmd/tpagectl entrypoint using the existing thwap-pagesd module
and wire it to the urfave/cli v3 framework. Version metadata variables
are injected via -ldflags.

closes #145
closes #147
Add build-tpagectl target with version, commit, and date injected
through -ldflags so releases carry reproducible build info.

closes #148
docs(roadmap): mark CLI phase 1 scaffold complete
All checks were successful
Test and Release / lint (pull_request) Successful in 4m27s
Test and Release / test (pull_request) Successful in 23m46s
0e8b57ebd7
Record completion of the tpagectl module structure, urfave/cli setup,
version metadata, and the decision to reuse the existing thwap-pagesd
Go module.

closes #149
closes #146
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-08-04 23:35:45 +00:00
the.auditor left a comment

Review

No blocking issues. Verified locally against the PR head (0e8b57e): go build -mod=vendor ./..., go vet ./..., and go test -race -count=1 ./cmd/tpagectl/ all pass; gofmt -l clean; go mod verify passes; vendor/modules.txt includes the new urfave/cli/v3 entry.

Functional checks:

  • make build-tpagectl builds dist/tpagectl (fresh worktree — go build -o dist/... creates the dir), and -ldflags "-X main.version/commit/date" correctly injects build metadata: tpagectl version dev, commit: 0e8b57e, built: <RFC3339>.
  • tpagectl --version prints via the custom VersionPrinter; no-args prints help and exits 0; an unknown flag prints Incorrect Usage plus the stderr error: line and exits 1.
  • Tests cover root wiring (name/usage/version) and --version output.

Suggestions

  1. cmd/tpagectl/main.go:32cli.VersionPrinter is set as a global side effect inside the newCommand() constructor. It's package-global mutable state that later subcommand trees or t.Parallel() tests could clobber. Prefer setting it once in main(). Filed as #536.

Notes (not blocking, not filed)

  • build-tpagectl is intentionally not part of all/build; worth wiring into all once the CLI gains commands.
  • -X main.version relies on the package being named main; fine today, just coupling to note if the entrypoint is ever restructured.

Praise

  • Clean scaffold: module reuse decision (#146) honored, single source for version/commit/date, Makefile vars follow the existing style, and the CLI entrypoint keeps main() trivial.
  • Good call wiring Version: version into the command so help renders the version too.

Approving.

## Review No blocking issues. Verified locally against the PR head (`0e8b57e`): `go build -mod=vendor ./...`, `go vet ./...`, and `go test -race -count=1 ./cmd/tpagectl/` all pass; `gofmt -l` clean; `go mod verify` passes; `vendor/modules.txt` includes the new `urfave/cli/v3` entry. Functional checks: - `make build-tpagectl` builds `dist/tpagectl` (fresh worktree — `go build -o dist/...` creates the dir), and `-ldflags "-X main.version/commit/date"` correctly injects build metadata: `tpagectl version dev`, `commit: 0e8b57e`, `built: <RFC3339>`. - `tpagectl --version` prints via the custom `VersionPrinter`; no-args prints help and exits 0; an unknown flag prints `Incorrect Usage` plus the stderr `error:` line and exits 1. - Tests cover root wiring (name/usage/version) and `--version` output. ## Suggestions 1. `cmd/tpagectl/main.go:32` — `cli.VersionPrinter` is set as a global side effect inside the `newCommand()` constructor. It's package-global mutable state that later subcommand trees or `t.Parallel()` tests could clobber. Prefer setting it once in `main()`. Filed as #536. ## Notes (not blocking, not filed) - `build-tpagectl` is intentionally not part of `all`/`build`; worth wiring into `all` once the CLI gains commands. - `-X main.version` relies on the package being named `main`; fine today, just coupling to note if the entrypoint is ever restructured. ## Praise - Clean scaffold: module reuse decision (#146) honored, single source for `version`/`commit`/`date`, Makefile vars follow the existing style, and the CLI entrypoint keeps `main()` trivial. - Good call wiring `Version: version` into the command so help renders the version too. Approving.
fuzzy merged commit 0e8b57ebd7 into main 2026-08-05 00:04:56 +00:00
fuzzy deleted branch feature/cli-scaffold 2026-08-05 00:04:56 +00:00
Sign in to join this conversation.
No reviewers
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!535
No description provided.