added 'block rm' subcommand

This commit is contained in:
Jarek Kowalski committed 2017-11-12 22:43:21 -08:00
1 parent 585b6ddcc1
commit 40a367f79e
1 file changed
+35
+35
View File
@@ -0,0 +1,35 @@
package cli
import (
"github.com/kopia/kopia/repo"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
var (
removeBlockCommand = blockCommands.Command("remove", "Remove block(s)").Alias("rm")
removeBlockIDs = removeBlockCommand.Arg("id", "IDs of blocks to remove").Required().Strings()
)
func runRemoveBlockCommand(context *kingpin.ParseContext) error {
rep := mustOpenRepository(nil)
defer rep.Close()
for _, blockID := range *removeBlockIDs {
if err := removeBlock(rep, blockID); err != nil {
return err
}
}
return nil
}
func removeBlock(r *repo.Repository, blockID string) error {
return r.Blocks.DeleteBlock(blockID)
}
func init() {
setupShowCommand(removeBlockCommand)
removeBlockCommand.Action(runRemoveBlockCommand)
}