aboutsummaryrefslogtreecommitdiff
path: root/cmd/bolt/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/bolt/main.go')
-rw-r--r--cmd/bolt/main.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd/bolt/main.go b/cmd/bolt/main.go
index 387ffa4..cfb9765 100644
--- a/cmd/bolt/main.go
+++ b/cmd/bolt/main.go
@@ -37,6 +37,11 @@ func NewApp() *cli.App {
Action: KeysCommand,
},
{
+ Name: "buckets",
+ Usage: "Retrieves a list of all buckets",
+ Action: BucketsCommand,
+ },
+ {
Name: "pages",
Usage: "Dumps page information for a database",
Action: PagesCommand,
@@ -151,6 +156,33 @@ func KeysCommand(c *cli.Context) {
}
}
+// BucketsCommand retrieves a list of all buckets.
+func BucketsCommand(c *cli.Context) {
+ path := c.Args().Get(0)
+ if _, err := os.Stat(path); os.IsNotExist(err) {
+ fatal(err)
+ return
+ }
+
+ db, err := bolt.Open(path, 0600)
+ if err != nil {
+ fatal(err)
+ return
+ }
+ defer db.Close()
+
+ err = db.With(func(tx *bolt.Tx) error {
+ for _, b := range tx.Buckets() {
+ logger.Println(b.Name())
+ }
+ return nil
+ })
+ if err != nil {
+ fatal(err)
+ return
+ }
+}
+
// PagesCommand prints a list of all pages in a database.
func PagesCommand(c *cli.Context) {
path := c.Args().Get(0)