@@ -10,45 +10,31 @@ import (
1010)
1111
1212func copyToClipboard (text string ) error {
13- // Try xclip first, then xsel, then wl-copy as fallbacks.
14- // These are common clipboard utilities on Linux.
15-
1613 var attempts []string
17-
18- // Helper to try a single command and record any errors.
1914 tryCmd := func (name string , args ... string ) bool {
2015 if _ , err := exec .LookPath (name ); err != nil {
2116 attempts = append (attempts , fmt .Sprintf ("%s not found" , name ))
2217 return false
2318 }
24-
2519 cmd := exec .Command (name , args ... )
2620 cmd .Stdin = strings .NewReader (text )
2721 if err := cmd .Run (); err != nil {
2822 attempts = append (attempts , fmt .Sprintf ("%s failed: %v" , name , err ))
2923 return false
3024 }
31-
3225 return true
3326 }
3427
35- // Try xclip
3628 if tryCmd ("xclip" , "-selection" , "clipboard" ) {
3729 return nil
3830 }
39-
40- // Try xsel as fallback
4131 if tryCmd ("xsel" , "--clipboard" , "--input" ) {
4232 return nil
4333 }
44-
45- // Try wl-copy for Wayland
4634 if tryCmd ("wl-copy" ) {
4735 return nil
4836 }
4937
50- // All attempts failed - return combined error message. Plain fmt.Errorf
51- // because gotext only scans cmd/modern, cmd/sqlcmd, and pkg/sqlcmd; calling
52- // localizer.Errorf from internal/pal would never make it into the catalog.
38+ // gotext only scans cmd/modern, cmd/sqlcmd, and pkg/sqlcmd, so this stays plain fmt.Errorf.
5339 return fmt .Errorf ("failed to copy to clipboard; tried xclip, xsel, wl-copy: %s" , strings .Join (attempts , "; " ))
5440}
0 commit comments