Skip to content

feat: aligned version output and full shell completion - #20

Merged
boeboe merged 4 commits into
mainfrom
feat/version-completion
Nov 7, 2026
Merged

boeboe merged 4 commits into
mainfrom
feat/version-completion

Conversation

@boeboe

@boeboe boeboe commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • version: one line on stdout, <name> <version> (tag <tag>, commit <commit>, built <built>, <libraries>, <go>, <goos>/<goarch>), the OT Fabric libraries of the build (go-ethernetip) after the build date. No leading v; the tag part is left out when there is no tag; a development build reports dev (also for pseudo-versions and +dirty), the full commit from runtime/debug build info (-dirty when modified; was the 7-character short SHA) and built unknown. go install …@vX.Y.Z reports that version.
  • version --json, and version with the global --format json / ETHERNETIPCTL_FORMAT=json: {"name","version","tag","commit","built","libraries","go","platform"} (libraries: [{"name","version"}]) in that order, every key present. --format text|table prints the line.
  • New internal/buildinfo (replaces versionOf); main.version/tag/commit/buildDate stay the ldflags targets, so the release workflow's ldflags is unchanged. Makefile: full commit SHA; VERSION/TAG only when HEAD is exactly on a tag (else dev).
  • Completion: bash, zsh, fish, PowerShell (unchanged, now asserted via __complete). Existing enum completion of --format, --type (read/write/tag write), reset --type kept. New: eds inspect|validate|codegen <file> complete .eds; eds generate --output .eds; eds codegen --output .go; adapter --config yaml|yml|json. Every other value flag (hosts, addresses, numbers, durations, forward-open --config assembly instance) and every host/path argument uses NoFileComp.
  • Docs: docs/commands.md (version flag and output), docs/json-output.md, README (completion sentence, command table), RELEASE.md v0.6.0.

Before / after

Before:

ethernetipctl version: 0.4.0
tag:         v0.4.0
commit:      7743ca69e3a5c030b5bb6f3a4572c11e04e73fee
build date:  2026-11-05T15:41:49Z
go version:  go1.27.3
platform:    darwin/arm64

After (release ldflags; then plain go build):

ethernetipctl 0.6.0 (tag v0.6.0, commit 3c66fda881214899c34f566307d8a47cd35d3f3f, built 2026-11-07T12:00:00Z, go-ethernetip 0.5.2, go1.27.3, darwin/arm64)
{"name":"ethernetipctl","version":"0.6.0","tag":"v0.6.0","commit":"3c66fda881214899c34f566307d8a47cd35d3f3f","built":"2026-11-07T12:00:00Z","libraries":[{"name":"go-ethernetip","version":"0.5.2"}],"go":"go1.27.3","platform":"darwin/arm64"}
ethernetipctl dev (commit 3c66fda881214899c34f566307d8a47cd35d3f3f-dirty, built unknown, go-ethernetip 0.5.2, go1.27.3, darwin/arm64)

Tests

  • internal/buildinfo: all fields, no tag, dev fallback, pseudo-version/+dirty -> dev, libraries (zero, one, two; replace and nested modules), embedded build info (-dirty), JSON key order.
  • internal/cli: CompleteTree unit test.
  • cmd: version text / --json / --format json|table / ETHERNETIPCTL_FORMAT=json / dev build; __complete for the four shells, enum flags, file and free-value directives; a walk over every command that fails when a value flag has no completion or a flag whose usage lists values does not complete them.
  • make check (fmt, staticcheck, golangci-lint, vet, 32-bit cross build, govulncheck, -race tests, coverage 95.9%, per-package coverage, docsync) and make e2e green locally.

🤖 Generated with Claude Code

version prints one line (name, version without v, tag, full commit, build
date, Go version, platform), or one JSON object with --json or --format
json. Missing values come from runtime/debug build info (commit with
-dirty) or are dev/unknown; internal/buildinfo replaces versionOf. The
release workflow's -X main.* ldflags are unchanged; the Makefile now
injects the full commit.

completion covers bash, zsh, fish and PowerShell. EDS arguments,
adapter --config and the --output of eds generate/codegen complete files
of their type; every other value flag and argument completes nothing
instead of file names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.60140% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/buildinfo/buildinfo.go 97.43% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

boeboe and others added 3 commits November 7, 2026 22:56
version lists the github.com/otfabric/go-* modules of the build after the
build date (text) and as libraries (JSON). A pseudo-version or +dirty
version from the build info is dev. make build injects a version and tag
only when HEAD is exactly on a tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test binaries of Go 1.26 carry no module dependencies in their build info,
so the unit test no longer requires the library there; the e2e suite
checks it on the built binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boeboe
boeboe merged commit f0161ae into main Nov 7, 2026
25 checks passed
@boeboe
boeboe deleted the feat/version-completion branch November 7, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant