dry run for forget cmd

This commit is contained in:
2021-04-11 14:22:46 +02:00
parent 05be58a3a7
commit 5d92b5bcc1
4 changed files with 12 additions and 2 deletions

View File

@@ -101,6 +101,9 @@ func GetAllOrSelected(cmd *cobra.Command, backends bool) ([]string, error) {
}
}
}
if len(selected) == 0 {
return selected, fmt.Errorf("nothing selected, aborting")
}
return selected, nil
}
}

View File

@@ -87,7 +87,7 @@ func (l Location) Backup() error {
return nil
}
func (l Location) Forget(prune bool) error {
func (l Location) Forget(prune bool, dry bool) error {
c := GetConfig()
from := GetPathRelativeToConfig(l.From)
for _, to := range l.To {
@@ -101,6 +101,9 @@ func (l Location) Forget(prune bool) error {
if prune {
cmd = append(cmd, "--prune")
}
if dry {
cmd = append(cmd, "--dry-run")
}
cmd = append(cmd, flags...)
out, err := ExecuteResticCommand(options, cmd...)
fmt.Println(out)