Skip to content

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

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

boeboe merged 3 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>). No leading v; the tag part is left out when there is no tag; the OT Fabric libraries of the build (go-profinet) follow the build date, as the old go-profinet: line did. 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.
  • version --json, and version with the global --format json / -o json / PROFINETCTL_FORMAT=json: {"name","version","tag","commit","built","libraries","go","platform"} in that order, libraries as [{"name","version"}]. --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). New value completion: --mrp-role (client, manager, off) and im read --record (0-4), next to the existing --format, --mode, --interface. Files by type: GSDML arguments of gsdml inspect|validate|check|modules|submodules and --gsdml (xml), gsdml gsdx (gsdx), --model/--expect (json), --pcap (pcap); --data-file, --output-file any file. Every other value flag and argument (stations, MACs, addresses, numbers, durations) uses NoFileComp.
  • Docs: docs/json-output.md, docs/EXAMPLES.md (version block; derived, not regenerated — make examples-doc needs Docker and p-net), README (completion sentence, command table), RELEASE.md v0.9.0.

Before / after

Before:

profinetctl version: 0.4.0
tag:         v0.4.0
commit:      351ecc322914fe6af49a9e416f1b9fe753b39b74
build date:  2026-11-05T15:41:49Z
go-profinet: v0.7.0
go version:  go1.27.3
platform:    darwin/arm64

After (release ldflags; then plain go build):

profinetctl 0.9.0 (tag v0.9.0, commit 351ecc322914fe6af49a9e416f1b9fe753b39b74, built 2026-11-07T12:00:00Z, go-profinet 0.7.0, go1.27.3, darwin/arm64)
{"name":"profinetctl","version":"0.9.0","tag":"v0.9.0","commit":"351ecc322914fe6af49a9e416f1b9fe753b39b74","built":"2026-11-07T12:00:00Z","libraries":[{"name":"go-profinet","version":"0.7.0"}],"go":"go1.27.3","platform":"darwin/arm64"}
profinetctl dev (commit 351ecc322914fe6af49a9e416f1b9fe753b39b74-dirty, built unknown, go-profinet 0.7.0, go1.27.3, darwin/arm64)

Tests

  • internal/buildinfo: all fields, no tag, dev fallback, pseudo-version/+dirty → dev, embedded build info (-dirty), libraries (zero, one, two; from build info with replace and nested modules), JSON key order.
  • cmd: version text / --json / -o json / --format table / PROFINETCTL_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 (release-notes-check, fmt, staticcheck, golangci-lint, vet, 32-bit cross build, govulncheck, -race tests, coverage 93.2%, per-package coverage, docsync) and make e2e green locally.

🤖 Generated with Claude Code

boeboe and others added 3 commits November 7, 2026 23:01
version prints one line (name, version without v, tag, full commit, build
date, the go-profinet version, Go version, platform), or one JSON object
with --json or --format/-o json. Missing values come from runtime/debug
build info (commit with -dirty; pseudo-versions are dev) or are
dev/unknown; internal/buildinfo replaces versionOf. The release
workflow's -X main.* ldflags are unchanged; the Makefile injects the full
commit, and a version and tag only when HEAD is on a tag.

completion covers bash, zsh, fish and PowerShell. --mrp-role and
im read --record complete their values next to --format, --mode and
--interface; GSDML, GSDX, model, expected-link and pcap files complete by
type, and every other value flag and argument completes nothing.

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>
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.73418% 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
boeboe merged commit a14597f into main Nov 7, 2026
27 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