mirror of
https://github.com/restic/restic.git
synced 2025-03-16 00:00:05 +01:00
Make JSON option global
This commit is contained in:
parent
b054ba0d72
commit
38d95a12a2
2 changed files with 3 additions and 2 deletions
|
@ -38,7 +38,6 @@ func init() {
|
|||
f := cmdSnapshots.Flags()
|
||||
f.StringVar(&snapshotOptions.Host, "host", "", "only print snapshots for this host")
|
||||
f.StringSliceVar(&snapshotOptions.Paths, "path", []string{}, "only print snapshots for this `path` (can be specified multiple times)")
|
||||
f.BoolVarP(&snapshotOptions.Json, "json", "", false, `print snapshots in json format`)
|
||||
}
|
||||
|
||||
func runSnapshots(opts SnapshotOptions, gopts GlobalOptions, args []string) error {
|
||||
|
@ -86,7 +85,7 @@ func runSnapshots(opts SnapshotOptions, gopts GlobalOptions, args []string) erro
|
|||
|
||||
}
|
||||
|
||||
if opts.Json == true {
|
||||
if gopts.JSON == true {
|
||||
jsonoutput(list)
|
||||
} else {
|
||||
naturaloutput(list)
|
||||
|
|
|
@ -31,6 +31,7 @@ type GlobalOptions struct {
|
|||
PasswordFile string
|
||||
Quiet bool
|
||||
NoLock bool
|
||||
JSON bool
|
||||
|
||||
password string
|
||||
stdout io.Writer
|
||||
|
@ -53,6 +54,7 @@ func init() {
|
|||
f.StringVarP(&globalOptions.PasswordFile, "password-file", "p", "", "read the repository password from a file")
|
||||
f.BoolVarP(&globalOptions.Quiet, "quiet", "q", false, "do not output comprehensive progress report")
|
||||
f.BoolVar(&globalOptions.NoLock, "no-lock", false, "do not lock the repo, this allows some operations on read-only repos")
|
||||
f.BoolVarP(&globalOptions.JSON, "json", "", false, `print snapshots in json format`)
|
||||
|
||||
restoreTerminal()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue