Example #1
0
func (c *listCommand) Run() error {
	buckets, err := clibolt.SplitBuckets(c.Arguments.Bucket)
	if err != nil {
		return err
	}
	err = clibolt.Bolt.State.DB.View(func(tx *bolt.Tx) error {
		bucket, err := clibolt.LookupBucket(tx, buckets)
		if err != nil {
			return err
		}
		c := bucket.Cursor()
		for k, v := c.First(); k != nil; k, v = c.Next() {
			if v == nil {
				// skip buckets
				continue
			}
			_, err := fmt.Println(clibolt.EncodeKey(k))
			if err != nil {
				return err
			}
		}
		return nil
	})
	return err
}
Example #2
0
func (c *bucketsCommand) runRoot() error {
	err := clibolt.Bolt.State.DB.View(func(tx *bolt.Tx) error {
		return tx.ForEach(func(name []byte, b *bolt.Bucket) error {
			_, err := fmt.Println(clibolt.EncodeKey(name))
			return err
		})
	})
	return err
}
Example #3
0
func (c *bucketsCommand) runSub(buckets [][]byte) error {
	err := clibolt.Bolt.State.DB.View(func(tx *bolt.Tx) error {
		bucket, err := clibolt.LookupBucket(tx, buckets)
		if err != nil {
			return err
		}
		c := bucket.Cursor()
		for k, v := c.First(); k != nil; k, v = c.Next() {
			if v != nil {
				// not a bucket
				continue
			}
			_, err := fmt.Println(clibolt.EncodeKey(k))
			if err != nil {
				return err
			}
		}
		return nil
	})
	return err
}