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"
|
"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"
|
const queued = "queued"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -20,7 +20,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch os.Args[1] {
|
switch os.Args[1] {
|
||||||
case "write", "read", "w", "r":
|
case "write", "read", "w", "r", "buckets", "bkts", "b":
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", usage)
|
fmt.Fprintf(os.Stderr, "%s\n", usage)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -79,5 +79,12 @@ func main() {
|
|||||||
|
|
||||||
return nil
|
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