Return errors, rather than printing them

This commit is contained in:
2025-05-30 01:08:43 +00:00
parent 74b8261bc8
commit 40f0f35f45
21 changed files with 253 additions and 183 deletions
+4 -4
View File
@@ -3,24 +3,24 @@
package core
import (
"errors"
"os/exec"
"github.com/rwinkhart/go-boilerplate/back"
"github.com/rwinkhart/libmutton/global"
)
// copyString copies a string to the clipboard.
func copyString(continuous bool, copySubject string) {
func copyString(continuous bool, copySubject string) error {
cmd := exec.Command("termux-clipboard-set")
back.WriteToStdin(cmd, copySubject)
err := cmd.Run()
if err != nil {
back.PrintError("Failed to copy to clipboard: "+err.Error(), global.ErrorClipboard, true)
return errors.New("unable to copy to clipboard: " + err.Error())
}
if !continuous {
LaunchClipClearProcess(copySubject)
}
return nil
}
// getClipCommands returns the commands for pasting and clearing the clipboard contents.