Skip to content

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

Merged
boeboe merged 1 commit into
mainfrom
feat/version-completion
Nov 7, 2026
Merged

boeboe merged 1 commit into
mainfrom
feat/version-completion

Conversation

@boeboe

@boeboe boeboe commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What changed

  • version prints one line, the format shared by every OT Fabric CLI: <name> <version> (tag <tag>, commit <sha>, built <date>, <otfabric libs>, <go>, <os>/<arch>). The tag part is left out when there is no tag. Without injected metadata, the version comes from the module version of a release (go install …@vX.Y.Z) or is dev (pseudo-versions and +dirty count as dev), and the commit comes from vcs.revision, with -dirty added when the tree was modified.
  • version --json (new) and OCPPCTL_FORMAT=json print one JSON line with the keys name, version, tag, commit, built, libraries, go, platform. The new key set is documented in docs/json-output.md.
  • New package internal/buildinfo, which replaces the inline version code in cmd/root.go.
  • Completion works for bash, zsh, fish and PowerShell. New completion for <Action> of client call/client send/server call/validate and for frame encode --action (actions of --ocpp-version that the command can send; every version when the flag is not set), for frame encode --error-code (the CALLERROR codes of the version), and for .yaml/.yml scenarios of client script. New cli.CompleteRest covers every other flag that takes a value: file flags (--config yaml/yml/json, TLS/PEM files, input/output/password files) complete files of their type, and addresses, numbers and names complete no file names. Commands without argument completion also complete no file names.
  • Makefile: VERSION/TAG are injected only when HEAD is exactly on a tag (any other build reports dev), the version has no leading v, and COMMIT is the full SHA. The release workflow ldflags were already correct and are unchanged.
  • README (Shell completion sentence, command tree, usage line), docs/json-output.md, RELEASE.md v0.4.0.

Before / after

Before:

ocppctl version: 0.3.0
tag:         v0.3.0
commit:      abc1234
build date:  2026-11-04T10:00:00Z
go version:  go1.26.x
platform:    linux/amd64

After (real output, local build with release ldflags):

ocppctl 0.4.0 (tag v0.4.0, commit 4997bc873237d586cf49bb315dbeae2b4cb4b7fb, built 2026-11-07T22:00:00Z, go-ocpp 0.2.0, go1.27.3, darwin/arm64)
{"name":"ocppctl","version":"0.4.0","tag":"v0.4.0","commit":"4997bc873237d586cf49bb315dbeae2b4cb4b7fb","built":"2026-11-07T22:00:00Z","libraries":[{"name":"go-ocpp","version":"0.2.0"}],"go":"go1.27.3","platform":"darwin/arm64"}

Tests

  • make check (fmt, staticcheck, golangci-lint, vet, govulncheck, race tests, coverage, per-package floor, docsync) passes, Total coverage: 95.6% (minimum 85%). make e2e passes.
  • buildinfo: the line with and without a tag, the dev fallbacks (including pseudo-versions and +dirty), JSON key order, libraries with zero, one and two entries, and libraries read from build info. cmd: the version line, --json and OCPPCTL_FORMAT.
  • __complete: the four shells, one enum flag per command group, and file and free-value flags. TestEveryFlagCompletes walks the tree and fails on any value flag without completion, and on any flag whose usage lists values but completes none.

🤖 Generated with Claude Code

version prints one line (name, version, tag, commit, build date, OT Fabric
libraries, Go version, platform); version --json and OCPPCTL_FORMAT=json print it as
one JSON object. Build metadata is resolved in internal/buildinfo, falling
back to the toolchain's build info.

Every flag that takes a value now completes: fixed values, files of their
type, or no file names; commands without argument completion complete no
file names. A tree walk test enforces it.

The Makefile injects the version and tag only on an exact tag, and the
full commit SHA.

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

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@boeboe
boeboe merged commit 90327fd into main Nov 7, 2026
23 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