diff --git a/changelog/unreleased/issue-4547 b/changelog/unreleased/issue-4547 index 619923055..edb1cf693 100644 --- a/changelog/unreleased/issue-4547 +++ b/changelog/unreleased/issue-4547 @@ -1,7 +1,7 @@ Enhancement: Add support for `--json` option to `version` command -Restic now supports outputting restic version and used go version and platform -target via json when using the version command. +Restic now supports outputting restic version and used go version, OS and +architecture via JSON when using the version command. https://github.com/restic/restic/issues/4547 https://github.com/restic/restic/pull/4553 diff --git a/cmd/restic/cmd_version.go b/cmd/restic/cmd_version.go index 3c625abd5..73469750f 100644 --- a/cmd/restic/cmd_version.go +++ b/cmd/restic/cmd_version.go @@ -26,18 +26,20 @@ Exit status is 0 if the command was successful, and non-zero if there was any er type jsonVersion struct { Version string `json:"version"` GoVersion string `json:"go_version"` - GoTarget string `json:"go_target"` + GoOS string `json:"go_os"` + GoArch string `json:"go_arch"` } jsonS := jsonVersion{ Version: version, GoVersion: runtime.Version(), - GoTarget: runtime.GOOS + "/" + runtime.GOARCH, + GoOS: runtime.GOOS, + GoArch: runtime.GOARCH, } err := json.NewEncoder(globalOptions.stdout).Encode(jsonS) if err != nil { - Warnf("Encode failed: %v\n", err) + Warnf("JSON encode failed: %v\n", err) return } } else { diff --git a/doc/075_scripting.rst b/doc/075_scripting.rst index 3be5cc4c9..f17e222cc 100644 --- a/doc/075_scripting.rst +++ b/doc/075_scripting.rst @@ -588,5 +588,7 @@ The version command returns a single JSON object. +----------------+--------------------+ | ``go_version`` | Go compile version | +----------------+--------------------+ -| ``go_target`` | Go target platform | +| ``go_os`` | Go OS | ++----------------+--------------------+ +| ``go_arch`` | Go architecture | +----------------+--------------------+