add "print buckets" subcommand

This commit is contained in:
Stephen McQuay 2016-08-22 17:58:06 -07:00
parent e4d9174597
commit e191dc36fa
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D

11
main.go
View File

@ -9,7 +9,7 @@ import (
"github.com/boltdb/bolt"
)
const usage = "bdb <(w)rite|(r)ead> <db>"
const usage = "bdb <(w)rite|(r)ead|(b)uckets> <db>"
const queued = "queued"
func main() {
@ -20,7 +20,7 @@ func main() {
}
switch os.Args[1] {
case "write", "read", "w", "r":
case "write", "read", "w", "r", "buckets", "bkts", "b":
default:
fmt.Fprintf(os.Stderr, "%s\n", usage)
os.Exit(1)
@ -79,5 +79,12 @@ func main() {
return nil
})
case "buckets", "bkts", "b":
db.View(func(tx *bolt.Tx) error {
return tx.ForEach(func(name []byte, _ *bolt.Bucket) error {
fmt.Printf("%s\n", name)
return nil
})
})
}
}