From e14a7db4ffe3c4e0f15f6b37a980501a8d74d26b Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 13 Aug 2026 13:04:10 +0200 Subject: Initial commit: prognosis, the Go implementation An hour-by-hour forecast for the terminal, with official IMGW warnings for Polish locations. Replaces the Python version, whose cache file format it keeps so the two can coexist until this reaches parity. Open-Meteo provides the forecast, geocoding and pollen; GUGiK turns coordinates into a TERYT powiat code; IMGW supplies the warnings, filtered to that powiat rather than the whole country. Only the two lookups that never change are cached. Forecasts never are. Silence is never allowed to read as all-clear: "no warnings in force" and "the check failed" are reported as distinct states. Place names are resolved without guessing. A name matching several places is refused with a numbered list carrying each candidate's region and coordinates, and -pick N chooses one and remembers it. A stray positional beside -l is an error, so an unquoted "Wiry, PL" cannot silently resolve to somewhere else. The cache is written one entry per line with sorted keys, and treated as disposable but not worthless: an entry that will not parse is skipped and the rest kept, and a file that will not parse at all is moved to cache.json.bad rather than overwritten. No third-party dependencies. `make ci` is the gate: gofmt clean, vet, tests. --- Makefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..40c3ad2 --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +.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 + +help: ## show this help + @grep -E '^[a-z-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[1m%-16s\033[0m %s\n", $$1, $$2}' + +build: ## build the Go binary into ./$(BIN) + go build -trimpath -ldflags "-s -w" -o $(BIN) ./cmd/prognosis + +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)" + + + +uninstall: ## remove the installed binary + rm -f $(INSTALL_PATH)/$(BIN) + +test: ## run the tests + go test ./... + +vet: ## go vet + go vet ./... + +fmt: ## gofmt the tree + gofmt -w . + +ci: ## pre-push gate: gofmt clean, vet, tests, 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); \ + 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 + @ls -la $(DIST) + + +clean: ## remove build artifacts + rm -rf $(BIN) $(DIST) -- cgit v1.3