Skip to content

feat(cli): enhance CLI version information#52

Open
Saisathvik94 wants to merge 3 commits into
optiqor:mainfrom
Saisathvik94:feature/version-info
Open

feat(cli): enhance CLI version information#52
Saisathvik94 wants to merge 3 commits into
optiqor:mainfrom
Saisathvik94:feature/version-info

Conversation

@Saisathvik94
Copy link
Copy Markdown

  • Embed commit hash, build date, Go version, and OS/architecture into binaries.
  • Update Makefile and .goreleaser.yaml to inject build metadata via ldflags.
  • Implement custom --version flag handling with a verbose option for detailed output.
  • Improve debuggability and traceability of deployed binaries.

What

  • Added ldflags-injectable build metadata variables (version, commit, buildDate) to the CLI entrypoint.
  • Updated .goreleaser.yaml to inject version, commit hash, and build date into release binaries.
  • Updated the Makefile to inject the same metadata during local builds.
  • Added verbose version output support to expose build metadata, Go runtime version, and target OS/architecture.
  • Preserved existing single-line --version behavior for backward compatibility.

Why

Providing build metadata in binaries improves traceability, debugging, and release verification. Users and maintainers can quickly determine exactly which source revision produced a binary, when it was built, and the runtime/platform it targets. This is especially useful when troubleshooting issues reported against released artifacts.

Fixes #10

How

  • Added package-level variables with sensible fallbacks:
    • version = "dev"
    • commit = "none"
    • buildDate = "unknown"
  • Injected values via Go linker flags in both GoReleaser and Makefile builds.
  • Implemented version reporting that:
    • keeps optiqor --version as a single-line output,
    • provides extended metadata when verbose version information is requested.
  • Included Go runtime version and OS/architecture information in verbose output.

Testing

  • make lint test passes locally
  • go test -race ./... passes
  • If a new rule: added a chart fixture in testdata/ and a golden output
  • Tested locally with:

Checklist

  • PR title follows Conventional Commits (feat(scope): subject)
  • All commits are DCO-signed (git commit -s)
  • No unrelated changes pulled in
  • Documentation updated where user-visible behavior changed
  • No LLM calls or telemetry introduced
  • No proprietary backend imports

*   Embed commit hash, build date, Go version, and OS/architecture into binaries.
*   Update `Makefile` and `.goreleaser.yaml` to inject build metadata via `ldflags`.
*   Implement custom `--version` flag handling with a verbose option for detailed output.
*   Improve debuggability and traceability of deployed binaries.
@Saisathvik94 Saisathvik94 requested a review from btwshivam as a code owner June 6, 2026 13:57
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

First PR — welcome aboard!

A few things to expect:

  1. CI: every PR runs build + race tests + lint on Ubuntu and macOS. If something fails, the log will tell you exactly which gate.
  2. DCO: every commit needs Signed-off-by:. git commit -s adds it automatically.
  3. Conventional Commits: PR titles like feat(analyze): new rule or fix(cli): handle X. We squash-merge by default.
  4. Review: a maintainer will review within 72 hours. Suggestions are conversations, not orders — push back if something doesn't fit your context.

If you get stuck, reply here or jump to Discussions. We want this PR to land.

@github-actions github-actions Bot added area/release Release tooling and packaging area/cli Cobra CLI commands and UX size/M 51–200 lines labels Jun 6, 2026
…ion` entry

* Add `--version --verbose` to the list of available commands.
* Include `--version --verbose` in the table of general flags.
* Explicitly list `--version` in the general flags table.
* Enhance clarity regarding CLI options in the README.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 6, 2026
@Saisathvik94 Saisathvik94 changed the title feat(version): Enhance CLI version information feat(cli): Enhance CLI version information Jun 6, 2026
@Saisathvik94 Saisathvik94 changed the title feat(cli): Enhance CLI version information feat(cli): enhance CLI version information Jun 6, 2026
* Replaced tab characters with spaces for variable declarations.
* Corrected indentation within the `main` function.
* Adjusted indentation for flags in the `newRootCmd` function.
* Ensured consistent code formatting throughout the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Cobra CLI commands and UX area/release Release tooling and packaging documentation Improvements or additions to documentation size/M 51–200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optiqor --version --verbose: expose commit, build date, Go version, target

1 participant