Repository navigation
feat: aligned version output and full shell completion - #23
Merged
Merged
Conversation
version prints one line, <name> <version> (tag <tag>, commit <sha>, built <date>, <go>, <goos>/<goarch>), and one JSON object with --json or SPARKPLUGBCTL_FORMAT=json. Missing build metadata falls back to the Go build information (go install @vX.Y.Z, VCS revision with -dirty), then to dev/unknown. The release workflow and Makefile inject the tag and the full commit SHA. Flag values complete: the metric type of --metric, certificate files for the TLS flags, no file names for free-value flags and argument-less commands. Tests cover __complete for all four shells and walk every flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…builds version lists the github.com/otfabric/go-* modules the binary is built on after the build date (go-sparkplugb 0.3.3), and --json gains a libraries array between built and go ([] when none). The Makefile injects VERSION and TAG only when HEAD is exactly on a tag, so a make build elsewhere reports dev. 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, aligned with the other OT Fabric CLIs, and one JSON object with--json(orSPARKPLUGBCTL_FORMAT=json):<name> <version> (tag <tag>, commit <sha>, built <date>, <go>, <goos>/<goarch>); the version has no leadingv, the tag part is left out without a tag.name,version,tag,commit,built,libraries,go,platform(documented indocs/json-output.md).github.com/otfabric/go-*dependency from the build info (replacement version when replaced), sorted by name, shown afterbuilt …asgo-sparkplugb 0.3.3;"libraries":[]in JSON when none.internal/buildinfopackage. Fallbacks when nothing is injected: version fromdebug.ReadBuildInfofor a releasedgo install …@vX.Y.Z(pseudo-versions and+dirtystamps ofgo buildcount asdev), commit fromvcs.revisionwith-dirty, elsedev/unknown.-X main.tag=${TAG}; the Makefile now injects the full commit SHA, and VERSION/TAG only when HEAD is exactly on a tag (otherwisedev). Variables staymain.version,main.commit,main.date.Shell completion:
completioncovers bash, zsh, fish and PowerShell (cobra default). New value completion:--metric(publish,edge,encode): aftername:it completes the 15 metric types asname:<Type>=.--tls-cert,--tls-ca:.pem/.crt/.cerfiles;--tls-key:.pem/.keyfiles.decode --file,encode --file: files.--broker,--client-id,--username,--password,--group,--node,--device,--interval,--primary-host,--host-id,--topic,--seq) and every command's positional args: no file completion.README: version section with the new output; one-sentence intro on the Shell completion subsection. RELEASE.md: v0.4.0 section.
Before / after
Before (
make buildon main):After (release-style ldflags):
After (
go build, andmake buildoff a tag):Tests
internal/buildinfo: text with all fields, without tag, dev fallback, VCS fallback with-dirty,go installversion, pseudo/dirty versions asdev, JSON key order and values, formatting with zero, one and two libraries (list injected), library selection from build info (main module, non-otfabric and replacements).cmd:versiontext,--json,SPARKPLUGBCTL_FORMAT=json|text;__completefor the four shells,--metrictypes on all three commands, TLS file extensions, no-file directives; a walk that fails when a value flag has no completion function or a leaf command noValidArgsFunction.make check(fmt, staticcheck, golangci-lint, vet, govulncheck,-racetests, coverage gate 100%, per-package floor, docsync) andmake e2egreen locally; binary run forversion,version --json,completion bash|zsh|fish|powershelland several__completecalls.🤖 Generated with Claude Code