Add --version flag and enforce --long flags via pflag
Switches CLI flag parsing from Go's stdlib `flag` to spf13/pflag so `--project` (and the internal `--socket` / `--identity` / `--scenario` flags) are the only accepted form; single-hyphen long flags like `-project` are now rejected. Help output renders the canonical `--` form. Adds `patterm --version`, which prints the build version, short commit, and build date (e.g. `patterm v0.0.1 (commit abc1234, built 2026-05-14)`). The version string is injected at build time — `make patterm` derives it from `git describe --tags --always --dirty`, and the release workflow injects the pushed tag. Commit/date come from the Go toolchain's embedded VCS info via `runtime/debug.ReadBuildInfo`, so no manual bumping is required.
This commit is contained in:
4
Makefile
4
Makefile
@@ -32,11 +32,13 @@ deps-build: $(INSTALL)/lib/libghostty-vt.a
|
||||
clean-deps:
|
||||
rm -rf $(SOURCE) $(INSTALL)
|
||||
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
|
||||
spike: deps
|
||||
go build -o ./bin/spike ./cmd/spike
|
||||
|
||||
patterm: deps
|
||||
go build -o ./bin/patterm ./cmd/patterm
|
||||
go build -ldflags "-X main.version=$(VERSION)" -o ./bin/patterm ./cmd/patterm
|
||||
|
||||
test: deps
|
||||
go test ./...
|
||||
|
||||
Reference in New Issue
Block a user