version: add message_type in --json mode

This commit is contained in:
Michael Terry 2024-07-28 08:36:19 -04:00
parent 33c670dd7a
commit 2d250a9135

View file

@ -25,6 +25,7 @@ Exit status is 1 if there was any error.
Run: func(_ *cobra.Command, _ []string) { Run: func(_ *cobra.Command, _ []string) {
if globalOptions.JSON { if globalOptions.JSON {
type jsonVersion struct { type jsonVersion struct {
MessageType string `json:"message_type"` // version
Version string `json:"version"` Version string `json:"version"`
GoVersion string `json:"go_version"` GoVersion string `json:"go_version"`
GoOS string `json:"go_os"` GoOS string `json:"go_os"`
@ -32,6 +33,7 @@ Exit status is 1 if there was any error.
} }
jsonS := jsonVersion{ jsonS := jsonVersion{
MessageType: "version",
Version: version, Version: version,
GoVersion: runtime.Version(), GoVersion: runtime.Version(),
GoOS: runtime.GOOS, GoOS: runtime.GOOS,