mirror of
https://github.com/restic/restic.git
synced 2025-12-14 02:57:04 +00:00
version: convert to termstatus
This commit is contained in:
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -24,6 +23,10 @@ Exit status is 1 if there was any error.
|
|||||||
`,
|
`,
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
Run: func(_ *cobra.Command, _ []string) {
|
Run: func(_ *cobra.Command, _ []string) {
|
||||||
|
term, cancel := setupTermstatus()
|
||||||
|
defer cancel()
|
||||||
|
printer := newTerminalProgressPrinter(globalOptions.JSON, globalOptions.verbosity, term)
|
||||||
|
|
||||||
if globalOptions.JSON {
|
if globalOptions.JSON {
|
||||||
type jsonVersion struct {
|
type jsonVersion struct {
|
||||||
MessageType string `json:"message_type"` // version
|
MessageType string `json:"message_type"` // version
|
||||||
@@ -43,14 +46,13 @@ Exit status is 1 if there was any error.
|
|||||||
|
|
||||||
err := json.NewEncoder(globalOptions.stdout).Encode(jsonS)
|
err := json.NewEncoder(globalOptions.stdout).Encode(jsonS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Warnf("JSON encode failed: %v\n", err)
|
printer.E("JSON encode failed: %v\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("restic %s compiled with %v on %v/%v\n",
|
printer.S("restic %s compiled with %v on %v/%v\n",
|
||||||
version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
Reference in New Issue
Block a user