catbase/util/bolthold/util.go

38 lines
618 B
Go
Raw Normal View History

2021-12-21 04:31:19 +00:00
package main
import (
"flag"
bh "github.com/timshannon/bolthold"
"os"
)
var (
storePath = flag.String("store", "rathaus.store", "store file")
action = flag.String("action", "", "action to perform")
what = flag.String("what", "", "what to clean")
)
func main() {
flag.Parse()
if *action == "" {
flag.Usage()
os.Exit(1)
}
store, err := bh.Open(*storePath, 0666, nil)
if err != nil {
panic(err)
}
defer store.Close()
if *action == "clear" && *what != "" {
tx, _ := store.Bolt().Begin(true)
err := tx.DeleteBucket([]byte(*what))
if err != nil {
panic(err)
}
tx.Commit()
}
}