From bab427b4f10598015a4ab43a4346351d6fa8eb23 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Fri, 19 Apr 2024 21:29:23 +0200 Subject: [PATCH 1/3] Fix terminal.ReadPassword on Windows --- helpers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helpers.go b/helpers.go index c4b6b64..78a857b 100644 --- a/helpers.go +++ b/helpers.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "syscall" "github.com/tobischo/gokeepasslib/v3" "golang.org/x/crypto/ssh/terminal" @@ -18,7 +19,7 @@ func readString(text string) (string, error) { func readPassword(text string) (string, error) { fmt.Print(text) - pw, err := terminal.ReadPassword(0) + pw, err := terminal.ReadPassword(int(syscall.Stdin)) if err != nil { return "", fmt.Errorf("Failed to read password: '%s'", err) } From 13c7205fc728858c9a41e24bb40540da6fdbbe3a Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Fri, 19 Apr 2024 21:30:17 +0200 Subject: [PATCH 2/3] Return entry if selection is unique --- entries.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/entries.go b/entries.go index 6e563ca..2a4c287 100644 --- a/entries.go +++ b/entries.go @@ -62,6 +62,10 @@ func readEntry(selection string, g *gokeepasslib.Group) (*gokeepasslib.Entry, er return nil, fmt.Errorf("No entry found") } + if len(entries) == 1 { + return readEntry(entries[0], g) + } + for i, entry := range entries { fmt.Printf("%3d %s\n", i, entry) } From 4ff2c61370e82cd04b8e19fbf5ad41ee69c50c52 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Fri, 19 Apr 2024 21:30:56 +0200 Subject: [PATCH 3/3] Print URL and UserName when copying the password --- copy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/copy.go b/copy.go index aaf1a09..214b0ea 100644 --- a/copy.go +++ b/copy.go @@ -20,6 +20,7 @@ func copyCmd(cmd *cobra.Command, args []string) error { markAsAccessed(entry) + fmt.Printf("URL: %s\n", entry.GetContent("URL")) fmt.Printf("UserName: %s\n", entry.GetContent("UserName")) return nil