Repository navigation
feat: aligned version output and full shell completion - #28
Merged
Merged
Conversation
version prints one line, name version (tag, commit, built, go, platform), and version --json (or MODBUSCTL_FORMAT=json) one JSON object with the keys name, version, tag, commit, built, go, platform. A development build falls back on the Go module version and VCS stamp. Every flag that takes a value now has a completion function: enum values, file extensions for input files, URL schemes, interfaces, and no file names for free values. make build stamps the full commit SHA. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
version names the github.com/otfabric/go-* modules the binary is built with after the build date, and version --json has a libraries array between built and go. Pseudo-versions and +dirty versions from the build info report dev. make build stamps VERSION and TAG only when HEAD is exactly on a tag; otherwise the binary reports dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <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 changed
versionprints one line:modbusctl <version> (tag <tag>, commit <sha>, built <date>, <go>, <goos>/<goarch>). The tag part is left out when the build has no tag; the version has no leadingv. A development build reportsdevand takes the commit from the Go VCS stamp (-dirtyfor a modified tree);go install …@vX.Y.Zreports that version. New packageinternal/buildinfo;main.*stays the ldflags target.version --json(new flag) andMODBUSCTL_FORMAT=json: one JSON object, keysname,version,tag,commit,built,go,platformin this order, always present.MODBUSCTL_FORMAT=text|tableprint the text line.completionalready offered bash, zsh, fish and PowerShell (tested via__complete). Every flag that takes a value now has a completion function (a walk test fails otherwise). New value completion:--functionof thecapturecommands (0-4),--missing,--before-first,--retry-timeout,--data-bits,--stop-bits,--baud,--familyand--value-kind(from the codec registry),--url(schemes),--interface(network interfaces); file completion by extension for--input(mbcap/jsonl/csv),--profile/--blocks-file(json),--tls-ca/--tls-cert/--tls-key(pem…);--outputcompletes any file; numbers, durations and addresses complete no file names. Commands without positional arguments complete no file names.make build:COMMITis the full SHA. Release workflow ldflags were already correct (-X main.version/tag/commit/buildDate).versionobject), RELEASE.md v3.6.0, e2e test.Follow-up commit (brief amendments)
github.com/otfabric/go-*modules of the build info, sorted) followbuilt …in the text line, andlibraries([{"name","version"}],[]when none) sits betweenbuiltandgoin the JSON.+dirtymodule versions reportdev.VERSIONandTAGonly when HEAD is exactly on a tag; otherwise empty and the binary reportsdev(archive names fall back todev).Before / after
Before (v3.5.1 built with release-style ldflags):
(
version --json:error: unknown flag: --json)After (release-style ldflags):
Plain
go build(a clean checkout off a tag):Tests run
make check(fmt-check, vet, staticcheck, golangci-lint, govulncheck, tests, coverage 96.5%),make e2e,go test -race ./cmd/... ./internal/buildinfoversion,version --json,MODBUSCTL_FORMAT=json version,completion bash|zsh|fish|powershell,__complete completion "",__complete capture decode --input "",__complete server replay --missing "",__complete client read --url t🤖 Generated with Claude Code