mirror of
https://github.com/kopia/kopia.git
synced 2026-02-24 02:18:39 -05:00
* 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>
29 lines
596 B
Go
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))
|
|
}
|