Files
kopia/cli/command_manifest_rm.go
Jarek Kowalski 6a14ac8a2a cli: ensure advanced commands are not accidentally used (#611)
* cli: ensure advanced commands are not accidentally used

This prints an error when a dangerous command is used without
first setting KOPIA_ADVANCED_COMMANDS=enabled environment variable.

Co-authored-by: Julio López <julio+gh@kasten.io>
2020-09-12 20:31:25 -07:00

29 lines
596 B
Go

package cli
import (
"context"
"github.com/kopia/kopia/repo"
)
var (
manifestRemoveCommand = manifestCommands.Command("rm", "Remove manifest items")
manifestRemoveItems = manifestRemoveCommand.Arg("item", "Items to remove").Required().Strings()
)
func runManifestRemoveCommand(ctx context.Context, rep repo.Repository) error {
advancedCommand()
for _, it := range toManifestIDs(*manifestRemoveItems) {
if err := rep.DeleteManifest(ctx, it); err != nil {
return err
}
}
return nil
}
func init() {
manifestRemoveCommand.Action(repositoryAction(runManifestRemoveCommand))
}