add "print buckets" subcommand
This commit is contained in:
parent
e4d9174597
commit
e191dc36fa
11
main.go
11
main.go
@ -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
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user