diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-13 13:04:10 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-13 13:04:10 +0200 |
| commit | e14a7db4ffe3c4e0f15f6b37a980501a8d74d26b (patch) | |
| tree | 670ef0897839871a64d3a3bb2e17e242e7d6c385 /Makefile | |
| download | prognosis-e14a7db4ffe3c4e0f15f6b37a980501a8d74d26b.tar.gz prognosis-e14a7db4ffe3c4e0f15f6b37a980501a8d74d26b.zip | |
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.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 56 |
1 files changed, 56 insertions, 0 deletions
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) |
