Debian Codegraph @

pb.go

raw symbols SCIP
1 package clipper
2
3 import (
4 "os/exec"
5 )
6
7 // pbpaste/pbcopy for macos
8 type Pb struct{}
9
10 func (pb *Pb) Init() error {
11 return verify(pb, "pbpaste", "pbcopy")
12 }
13
14 func (pb *Pb) ReadAll(reg string) ([]byte, error) {
15 if reg != RegClipboard {
16 return nil, &ErrInvalidReg{
17 Reg: reg,
18 }
19 }
20 cmd := exec.Command("pbpaste")
21 return cmd.Output()
22 }
23
24 func (pb *Pb) WriteAll(reg string, p []byte) error {
25 if reg != RegClipboard {
26 return &ErrInvalidReg{
27 Reg: reg,
28 }
29 }
30 cmd := exec.Command("pbcopy")
31 return write(cmd, p)
32 }