finalized conversion to protobuf:

- fixed import+export
- generalized file options
- always store keys as lowercase
- fixed+enhanced docs
- fixed tests
This commit is contained in:
2024-12-30 12:12:02 +01:00
parent bb5c268ca8
commit 1eb5efae0c
15 changed files with 128 additions and 152 deletions

View File

@@ -35,16 +35,18 @@ type DbAttr struct {
Binary bool
}
// check if value is to be read from a file or stdin, setup preview
// text according to flags, lowercase key
func (attr *DbAttr) ParseKV() error {
attr.Key = strings.ToLower(attr.Args[0])
switch len(attr.Args) {
case 1:
// 1 arg = key + read from file or stdin
attr.Key = attr.Args[0]
if attr.File == "" {
attr.File = "-"
}
case 2:
attr.Key = attr.Args[0]
attr.Val = []byte(attr.Args[1])
if attr.Args[1] == "-" {
@@ -58,9 +60,12 @@ func (attr *DbAttr) ParseKV() error {
}
}
if attr.Binary {
switch {
case attr.Binary:
attr.Preview = "<binary-content>"
case attr.Encrypted:
attr.Preview = "<encrypted-content>"
} else {
default:
if len(attr.Val) > MaxValueWidth {
attr.Preview = string(attr.Val)[0:MaxValueWidth] + "..."
@@ -74,9 +79,6 @@ func (attr *DbAttr) ParseKV() error {
attr.Preview = string(attr.Val)
}
}
if attr.Encrypted {
attr.Preview = "<encrypted-content>"
}
return nil
}