mirror of https://github.com/velour/catbase.git
38 lines
618 B
Go
38 lines
618 B
Go
|
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()
|
||
|
}
|
||
|
}
|