Commit 5b0aabc
authored
Add --version flag to print build info (#411)
## 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 (8ddeeee, 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:
- [x] Written a clear PR title and description (above)
- [x] Signed the [Khan Academy CLA](https://www.khanacademy.org/r/cla)
- [x] Added tests covering my changes, if applicable
- [x] Included a link to the issue fixed, if applicable
- [x] Included documentation, for new features
- [x] Added an entry to the changelog1 parent 8ddeeee commit 5b0aabc
2 files changed
+46
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
71 | 109 | | |
72 | 110 | | |
73 | 111 | | |
| |||
83 | 121 | | |
84 | 122 | | |
85 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
86 | 130 | | |
87 | 131 | | |
88 | 132 | | |
| |||
0 commit comments