Browse Source

add "print buckets" subcommand

master
Stephen McQuay 3 years ago
parent
commit
e191dc36fa
No known key found for this signature in database GPG Key ID: 1ABF428F71BAFC3D
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      main.go

+ 9
- 2
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
})
})
}
}

Loading…
Cancel
Save