From c2e580176995258457d3a33d031b6544ef95ccb6 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 17 Jul 2023 20:59:17 +0200 Subject: [PATCH] Add copy to clipboard flag for ssh key creation --- cmd/ssh.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/ssh.go b/cmd/ssh.go index b47f94a..69889c9 100644 --- a/cmd/ssh.go +++ b/cmd/ssh.go @@ -6,6 +6,7 @@ package cmd import ( "fmt" + "github.com/atotto/clipboard" "github.com/quexten/goldwarden/client" "github.com/quexten/goldwarden/ipc" "github.com/spf13/cobra" @@ -42,6 +43,8 @@ var sshAddCmd = &cobra.Command{ case ipc.CreateSSHKeyResponse: response := result.(ipc.CreateSSHKeyResponse) fmt.Println(response.Digest) + clipboard.WriteAll(string(response.Digest)) + break case ipc.ActionResponse: println("Error: " + result.(ipc.ActionResponse).Message) return @@ -80,5 +83,6 @@ func init() { sshCmd.AddCommand(sshAddCmd) sshAddCmd.PersistentFlags().String("name", "", "") sshAddCmd.MarkFlagRequired("name") + sshAddCmd.PersistentFlags().Bool("--clipboard", false, "Copy the public key to the clipboard") sshCmd.AddCommand(listSSHCmd) }