forked from TrueCloudLab/restic
error in case of unknown grouping option
This commit is contained in:
parent
1073bfba37
commit
8f9ef4402b
2 changed files with 17 additions and 7 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -95,10 +96,19 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
|
||||||
var GroupByTag bool
|
var GroupByTag bool
|
||||||
var GroupByHost bool
|
var GroupByHost bool
|
||||||
var GroupByPath bool
|
var GroupByPath bool
|
||||||
|
var GroupOptionList []string
|
||||||
|
|
||||||
GroupByTag = strings.Contains( opts.GroupBy, "tag" )
|
GroupOptionList = strings.Split( opts.GroupBy, "," )
|
||||||
GroupByHost = strings.Contains( opts.GroupBy, "host" )
|
|
||||||
GroupByPath = strings.Contains( opts.GroupBy, "path" )
|
for _, option := range GroupOptionList {
|
||||||
|
switch( option ) {
|
||||||
|
case "host": GroupByHost = true
|
||||||
|
case "paths": GroupByPath = true
|
||||||
|
case "tags": GroupByTag = true
|
||||||
|
case "":
|
||||||
|
default: return errors.Fatal( "unknown grouping option: '" + option + "'" )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(gopts.ctx)
|
ctx, cancel := context.WithCancel(gopts.ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
@ -50,10 +50,6 @@ data after 'forget' was run successfully, see the 'prune' command.
|
||||||
\fB\-\-keep\-tag\fP=[]
|
\fB\-\-keep\-tag\fP=[]
|
||||||
keep snapshots with this \fB\fCtaglist\fR (can be specified multiple times)
|
keep snapshots with this \fB\fCtaglist\fR (can be specified multiple times)
|
||||||
|
|
||||||
.PP
|
|
||||||
\fB\-G\fP, \fB\-\-group\-by\-tags\fP[=false]
|
|
||||||
Group by host,paths,tags instead of just host,paths
|
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-host\fP=""
|
\fB\-\-host\fP=""
|
||||||
only consider snapshots with the given \fB\fChost\fR
|
only consider snapshots with the given \fB\fChost\fR
|
||||||
|
@ -70,6 +66,10 @@ data after 'forget' was run successfully, see the 'prune' command.
|
||||||
\fB\-\-path\fP=[]
|
\fB\-\-path\fP=[]
|
||||||
only consider snapshots which include this (absolute) \fB\fCpath\fR (can be specified multiple times)
|
only consider snapshots which include this (absolute) \fB\fCpath\fR (can be specified multiple times)
|
||||||
|
|
||||||
|
.PP
|
||||||
|
\fB\-g\fP, \fB\-\-group\-by\fP="host,paths"
|
||||||
|
string for grouping snapshots by host,paths,tags
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-n\fP, \fB\-\-dry\-run\fP[=false]
|
\fB\-n\fP, \fB\-\-dry\-run\fP[=false]
|
||||||
do not delete anything, just print what would be done
|
do not delete anything, just print what would be done
|
||||||
|
|
Loading…
Reference in a new issue