feat(cli): add --version flag - #2
Merged
Merged
Conversation
The binary could not report its own version: `logscry --version` failed with "flag provided but not defined: -version". Resolve the version hybrid, in order: an `-X main.version` ldflags stamp (injected by `make build` from `git describe --tags --always --dirty`) wins; else the module version from `debug.ReadBuildInfo()`, ignoring the "(devel)" placeholder; else "dev". ldflags alone is not enough — the primary install path `go install .../logscry@latest` never runs the Makefile and would report "dev"; BuildInfo makes that path report the real tag. The flag is checked in config.Load right after flag parsing and short-circuits before the file is read or validated, so `logscry --version` prints and exits 0 even with a missing or invalid config. It is registered on the same flag set as `--config`, so `-h` lists it alongside every other flag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reasoning/thinking models (qwen3, deepseek-r1) can spend the whole default 300-token budget on chain-of-thought and return empty content with `finish_reason: length`; note the symptom and the fix in the Configuration section, and that non-reasoning models like gemma2:2b are fine at the default. Add --version to the flags table. Tick both M7 backlog items and record the --version item and its hybrid-resolution rationale. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
logscry --versionpreviously failed withflag provided but not defined: -version— the binary had no way to report its own version. This adds the flag, plus two documentation riders from the M7 backlog.How
Version resolution is a small pure helper with a three-step precedence:
-X main.version=…), set by theMakefilefromgit describe;debug.ReadBuildInfo().Main.Version—(devel)treated as absent,vcs.modified→-dirty;dev.ldflags alone would not be enough: the primary install path for a Go CLI is
go install …@latest, which never runs theMakefile, so those binaries would all reportdev. BuildInfo covers that path — verified withgo version -mon Go 1.26, where both a clean build at a tagged commit andgo install …@latestyield the tag.The flag is registered on the same flag set as the rest of the configuration, so
-hstill lists everything in one place, and it short-circuitsconfig.Loadimmediately after parsing — before the config file is read and before any validation.logscry --versiontherefore works with a missing or invalidlogscry.yaml.Also
--llm-max-tokensfor reasoning models — such a model spends its whole budget on chain-of-thought and returns empty content withfinish_reason: length, so the default of 300 is too low.--version.Verification
gofmt,go vet,golangci-lint run(0 issues),go test ./...,go test -race ./...,go build ./...— all green.(devel)/ dirty tree.go run→logscry dev;make build→ thegit describestring;--version --config /nonexistent.yaml→ prints and exits 0;-hlists-version.No changes to the pipeline, scoring, grouping, LLM backend, or TUI.