mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 23:09:08 +00:00
Implementing output to clipboard for resources
subcommand
This commit is contained in:
parent
61c45be091
commit
bf985e9da9
2 changed files with 185 additions and 0 deletions
27
util/clipboard.go
Normal file
27
util/clipboard.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"golang.design/x/clipboard"
|
||||
)
|
||||
|
||||
var delaySeconds int = 5
|
||||
|
||||
// SetDelay Set the delay between entries
|
||||
func SetDelay(delay int) {
|
||||
delaySeconds = delay
|
||||
}
|
||||
|
||||
/*
|
||||
CopyValueToClipboard Copy the given value to clipboard and sleeps for seconds defined with SetDelay (default: 5 seconds).
|
||||
|
||||
After the delay the clipboard will be emptied
|
||||
*/
|
||||
func CopyValueToClipboard(entryName string, value string) {
|
||||
clipboard.Write(clipboard.FmtText, []byte(value))
|
||||
fmt.Printf("Copying %s to clipboard...\n", entryName)
|
||||
time.Sleep(time.Duration(delaySeconds) * time.Second)
|
||||
clipboard.Write(clipboard.FmtText, []byte{})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue