commit 907e15b47fb4cf86a806f4ee53f031f07e651a3c
parent 036116b8955a9120c4fd323d99ce63076d23a46e
Author: Sean Enck <sean@ttypty.com>
Date: Sat, 17 Sep 2022 10:28:40 -0400
provide an output
Diffstat:
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/internal/subcommands/kdbx.go b/internal/subcommands/kdbx.go
@@ -3,6 +3,7 @@ package subcommands
import (
"errors"
"flag"
+ "fmt"
"os"
"path/filepath"
"strings"
@@ -48,8 +49,12 @@ func ToKeepass(args []string) error {
if err != nil {
return err
}
+ if len(entries) == 0 {
+ return errors.New("nothing to convert")
+ }
root := gokeepasslib.NewGroup()
root.Name = "root"
+ count := 0
for _, entry := range entries {
e := gokeepasslib.NewEntry()
path := entry.Path
@@ -63,6 +68,7 @@ func ToKeepass(args []string) error {
e.Values = append(e.Values, protectedValue("Password", val))
}
root.Entries = append(root.Entries, e)
+ count++
}
db := &gokeepasslib.Database{
Header: gokeepasslib.NewHeader(),
@@ -86,5 +92,6 @@ func ToKeepass(args []string) error {
if err := encoder.Encode(db); err != nil {
return err
}
+ fmt.Printf("exported %d entries to %s\n", count, fileName)
return nil
}
diff --git a/tests/expected.log b/tests/expected.log
@@ -48,6 +48,7 @@ remove entry? (y/N) HOOK RAN remove post
remove entry? (y/N) HOOK RAN remove post
+exported 1 entries to bin/file.kdbx
display command failed to retrieve data (decrypt not ok)
rekeying: /keys/one2.lb
test2
diff --git a/tests/run.sh b/tests/run.sh
@@ -51,6 +51,7 @@ _run() {
echo
yes 2>/dev/null | "$BIN/lb" rm test/totp
echo
+ "$BIN/lb" kdbx -file bin/file.kdbx
LOCKBOX_KEY="invalid" "$BIN/lb" show keys/one2
"$BIN/lb" "rekey" -outkey "test" -outmode "plaintext"
"$BIN/lb" rw -file bin/lb/keys/one2.lb -key "test" -keymode "plaintext" -mode "decrypt"