mirror of
https://github.com/kopia/kopia.git
synced 2026-10-22 06:04:47 -04:00
added 'block rm' subcommand
This commit is contained in:
1 parent
585b6ddcc1
commit
40a367f79e
1 file changed
+35
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user