Skip to content

Conversation

@irubey
Copy link
Contributor

@irubey irubey commented Nov 13, 2025

Summary

Adds a --version flag to the genqlient CLI that displays version information including commit hash and build date.

Changes

  • Added --version flag to generate/cliArgs struct
  • Implemented printVersion() function that uses runtime/debug.BuildInfo to extract:
    • Module version (or "dev" for development builds)
    • Git commit hash (shortened to 12 characters)
    • Build timestamp
  • Updated changelog with new feature entry

Example Output

For development builds:

genqlient dev (8ddeeee0a15a, built 2025-10-28T05:47:17Z)

For release builds:

genqlient v1.2.3 (abc123def456, built 2025-10-28T05:47:17Z)

Testing

  • ✅ All existing tests pass
  • ✅ Lint passes (make lint)
  • ✅ Manually tested with go run . --version and go build + ./genqlient --version
  • ✅ Help output correctly shows the new flag

Notes

The version flag follows common CLI conventions and provides useful debugging information. Pseudo-versions (like v0.0.0-...) are normalized to "dev" for cleaner output, while real version tags display normally.

Issue #296

I have:

  • Written a clear PR title and description (above)
  • Signed the Khan Academy CLA
  • Added tests covering my changes, if applicable
  • Included a link to the issue fixed, if applicable
  • Included documentation, for new features
  • Added an entry to the changelog

Copy link
Member

@csilvers csilvers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me! I'm approving, but @benjaminjkraft may have feedback he wants to give too (like other version info to report, or some such). But I think it's fine to land this as-is and iterate if need be.

Copy link
Collaborator

@benjaminjkraft benjaminjkraft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, thanks!

@benjaminjkraft benjaminjkraft merged commit 5b0aabc into Khan:main Nov 19, 2025
4 of 5 checks passed
@irubey irubey deleted the add-version-flag branch November 19, 2025 15:24
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.

3 participants