added -N flag, added -m template support to get and list commands

This commit is contained in:
2024-12-20 11:53:09 +01:00
parent ba39e3f8cd
commit d94868132d
7 changed files with 143 additions and 70 deletions

View File

@@ -13,6 +13,8 @@ import (
bolt "go.etcd.io/bbolt"
)
const MaxValueWidth int = 60
type DB struct {
Debug bool
Dbfile string
@@ -27,6 +29,26 @@ type DbEntry struct {
Bin []byte `json:"bin"`
Tags []string `json:"tags"`
Created time.Time `json:"created"`
Size int
}
// Post process an entry for list output.
// Do NOT call it during write processing!
func (entry *DbEntry) Normalize() {
entry.Size = len(entry.Value)
if entry.Encrypted {
entry.Value = "<encrypted-content>"
}
if len(entry.Bin) > 0 {
entry.Value = "<binary-content>"
entry.Size = len(entry.Bin)
}
if len(entry.Value) > MaxValueWidth {
entry.Value = entry.Value[0:MaxValueWidth] + "..."
}
}
type DbEntries []DbEntry