Implement unique clipboard clearing behavior for interactive GUI/TUI implementations

This commit is contained in:
2024-12-20 20:29:16 -05:00
parent f2f9c523f4
commit 619e4220a6
7 changed files with 56 additions and 56 deletions
+23
View File
@@ -0,0 +1,23 @@
//go:build !returnOnExit
package core
import (
"fmt"
"os"
"os/exec"
)
// launchClipClear launches the automated clipboard clearing process.
// For non-interactive CLI implementations, an entirely separate process is created for this purpose.
func launchClipClear(copySubject string) {
executableName := os.Args[0]
cmd := exec.Command(executableName, "clipclear")
writeToStdin(cmd, copySubject)
err := cmd.Start()
if err != nil {
fmt.Println(AnsiError + "Failed to launch automated clipboard clearing process - Does this libmutton implementation support the \"clipclear\" argument?" + AnsiReset)
os.Exit(ErrorClipboard)
}
os.Exit(0) // use os.Exit directly since this version of this function is only meant for non-interactive CLI implementations
}