diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-25 15:42:55 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-25 15:42:55 +0200 |
| commit | 92e1106b91f836339a957312a1ea4449c55114c7 (patch) | |
| tree | ee3726c567054e3f3a4eec692dcf5fb49099318b /Makefile | |
| parent | e14a7db4ffe3c4e0f15f6b37a980501a8d74d26b (diff) | |
| download | prognosis-0.1.1.tar.gz prognosis-0.1.1.zip | |
Stand alone, document, and let the config show anythingv0.1.1
prognosis no longer reads ~/.wegorc. Falling back to another program's
configuration made it useless without wego installed, and hid the fact that
it has no way to know where you are: location= is now required in its own
config, and the error says so and shows how to set it.
Custom columns. Any field the two Open-Meteo APIs expose can be displayed by
declaring it -- column.birch = air:birch_pollen -- and then naming it in
columns=. The source is explicit because forecast and air-quality are separate
services with separate fields; an air column costs one extra request, made only
when one is declared. Air values merge onto forecast hours by timestamp rather
than array index, since nothing guarantees the two endpoints start at the same
hour and merging by position would shift a column by an hour unnoticed. A value
the API withholds renders blank, not zero: for an allergen those are different
claims.
Pollen selection no longer privileges grass. A species named in pollen= is
shown even at zero, because you named it for a reason; pollen=all shows only
what is present, or the line is six zeroes. Grass had been special-cased, which
forced it on someone allergic to birch while hiding theirs.
Temperature colours are compared in Celsius whatever the display units. In
imperial, 85F -- a mild 29C -- was rendering in the red that means IMGW would
issue a heat warning.
A man page, checked by make lint and installed by make install. The Makefile
gains PREFIX/DESTDIR for packaging, a version stamped into the binary, a
release target that refuses to tag a dirty tree or a version with no changelog
entry, cross-compilation for six platforms, and a pre-push hook.
Also: humidity in the default columns, -weather for output meant for someone
else, -ascii so an SMS stays in GSM-7 rather than dropping to 70-character
UCS-2 segments, and -pollen and -version.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 89 |
1 files changed, 62 insertions, 27 deletions
@@ -1,31 +1,45 @@ .POSIX: -DESTDIR=$(HOME) -PREFIX=/.local -INSTALL_PATH=$(DESTDIR)$(PREFIX)/bin -BIN=prognosis -DIST=dist -.PHONY: help build install uninstall test vet fmt ci cross clean +# Standard GNU-ish install variables, so a packager can redirect everything: +# make install PREFIX=/usr DESTDIR=/tmp/pkg +DESTDIR ?= +PREFIX ?= $(HOME)/.local +BINDIR := $(DESTDIR)$(PREFIX)/bin +MANDIR := $(DESTDIR)$(PREFIX)/share/man/man1 -help: ## show this help - @grep -E '^[a-z-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[1m%-16s\033[0m %s\n", $$1, $$2}' +BIN := prognosis +DIST := dist +MODULE := github.com/lukaszkasprzak/prognosis + +# Version comes from git when there is a tag, "dev" otherwise, and is stamped +# into the binary so -version reports something meaningful. +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) +GOFLAGS := -trimpath +LDFLAGS := -s -w -X main.version=$(VERSION) + +PLATFORMS := linux/amd64 linux/arm64 android/arm64 darwin/amd64 darwin/arm64 freebsd/amd64 -build: ## build the Go binary into ./$(BIN) - go build -trimpath -ldflags "-s -w" -o $(BIN) ./cmd/prognosis +.PHONY: help build install uninstall test vet fmt lint ci cross release install-hooks clean -install: build ## build and install the Go binary - mkdir -p $(INSTALL_PATH) - # rm first: the target may be a symlink into this repo (see `link`), and cp - # follows symlinks -- it would write the binary over bin/prognosis itself. - rm -f $(INSTALL_PATH)/$(BIN) - cp $(BIN) $(INSTALL_PATH)/$(BIN) - chmod 755 $(INSTALL_PATH)/$(BIN) - @echo "Installed. Config: $$($(INSTALL_PATH)/$(BIN) -config)" +help: ## show this help + @grep -E '^[a-z-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ + awk 'BEGIN {FS = ":.*?## "}; {printf " \033[1m%-14s\033[0m %s\n", $$1, $$2}' + @echo + @echo " version: $(VERSION) prefix: $(PREFIX)" +build: ## build ./$(BIN) + go build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BIN) ./cmd/prognosis +install: build ## install the binary and man page + mkdir -p $(BINDIR) $(MANDIR) + # rm first: the target may be a symlink, and cp follows symlinks. + rm -f $(BINDIR)/$(BIN) + install -m 755 $(BIN) $(BINDIR)/$(BIN) + install -m 644 man/prognosis.1 $(MANDIR)/prognosis.1 + @echo "installed $(BINDIR)/$(BIN) and $(MANDIR)/prognosis.1" -uninstall: ## remove the installed binary - rm -f $(INSTALL_PATH)/$(BIN) +uninstall: ## remove the installed binary and man page + rm -f $(BINDIR)/$(BIN) $(MANDIR)/prognosis.1 test: ## run the tests go test ./... @@ -36,21 +50,42 @@ vet: ## go vet fmt: ## gofmt the tree gofmt -w . -ci: ## pre-push gate: gofmt clean, vet, tests, no third-party deps +lint: ## check the man page renders without warnings + @out=$$(man --warnings -l man/prognosis.1 2>&1 >/dev/null); \ + test -z "$$out" || { echo "man page warnings:"; echo "$$out"; exit 1; } + @echo "man page ok" + +ci: ## the gate: gofmt, vet, tests, man page, and no third-party deps @test -z "$$(gofmt -l .)" || { echo "gofmt needed:"; gofmt -l .; exit 1; } go vet ./... go test ./... - @deps=$$(go list -deps ./... | grep -E '^[a-z0-9-]+\.[a-z]+/' | grep -v '^github.com/lukaszkasprzak/prognosis' || true); \ + @$(MAKE) --no-print-directory lint + @deps=$$(go list -deps ./... | grep -E '^[a-z0-9-]+\.[a-z]+/' | grep -v '^$(MODULE)' || true); \ test -z "$$deps" || { echo "third-party dependencies crept in:"; echo "$$deps"; exit 1; } @echo "ci ok" -cross: ## cross-compile into $(DIST)/ -- android/arm64 is the phone - mkdir -p $(DIST) - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o $(DIST)/$(BIN)-linux-amd64 ./cmd/prognosis - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o $(DIST)/$(BIN)-linux-arm64 ./cmd/prognosis - CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o $(DIST)/$(BIN)-android-arm64 ./cmd/prognosis +cross: ## cross-compile every platform into $(DIST)/ + @mkdir -p $(DIST) + @for p in $(PLATFORMS); do \ + os=$${p%/*}; arch=$${p#*/}; \ + echo " $$os/$$arch"; \ + CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch \ + go build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(DIST)/$(BIN)-$$os-$$arch ./cmd/prognosis || exit 1; \ + done @ls -la $(DIST) +release: ## tag a release: make release VERSION=0.2.0 (add its CHANGELOG entry first) + @test "$(VERSION)" != "dev" || { echo "give a version: make release VERSION=0.2.0"; exit 1; } + @grep -q "^## $(VERSION)" CHANGELOG.md || \ + { echo "CHANGELOG.md has no '## $(VERSION)' entry; write it first"; exit 1; } + @test -z "$$(git status --porcelain)" || { echo "working tree is dirty"; exit 1; } + @$(MAKE) --no-print-directory ci + git tag -a v$(VERSION) -m "prognosis v$(VERSION)" + @echo "tagged v$(VERSION); push it with: git push --tags" + +install-hooks: ## install the pre-push hook that runs make ci + install -m 755 scripts/hooks/pre-push .git/hooks/pre-push + @echo "installed .git/hooks/pre-push" clean: ## remove build artifacts rm -rf $(BIN) $(DIST) |
