2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

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,17 +25,19 @@ 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 {
Version string `json:"version"` MessageType string `json:"message_type"` // version
GoVersion string `json:"go_version"` Version string `json:"version"`
GoOS string `json:"go_os"` GoVersion string `json:"go_version"`
GoArch string `json:"go_arch"` GoOS string `json:"go_os"`
GoArch string `json:"go_arch"`
} }
jsonS := jsonVersion{ jsonS := jsonVersion{
Version: version, MessageType: "version",
GoVersion: runtime.Version(), Version: version,
GoOS: runtime.GOOS, GoVersion: runtime.Version(),
GoArch: runtime.GOARCH, GoOS: runtime.GOOS,
GoArch: runtime.GOARCH,
} }
err := json.NewEncoder(globalOptions.stdout).Encode(jsonS) err := json.NewEncoder(globalOptions.stdout).Encode(jsonS)