added db info command

This commit is contained in:
Thomas von Dein
2024-12-22 00:07:33 +01:00
committed by T.v.Dein
parent 3de65aa1c3
commit 8e400c6831
4 changed files with 80 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ import (
"github.com/tlinden/anydb/app"
"github.com/tlinden/anydb/cfg"
"golang.org/x/term"
//"github.com/alecthomas/repr"
)
func Print(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.DbEntry) error {
@@ -93,3 +94,14 @@ func WriteFile(writer io.Writer, conf *cfg.Config, attr *app.DbAttr, entry *app.
return nil
}
func Info(writer io.Writer, conf *cfg.Config, info *app.DbInfo) error {
// repr.Println(info)
fmt.Fprintf(writer, "Database: %s\n", info.Path)
for _, bucket := range info.Buckets {
fmt.Fprintf(writer, "Bucket: %s\n Size: %d\n Keys: %d\n\n", bucket.Name, bucket.Size, bucket.Keys)
}
return nil
}