-
Notifications
You must be signed in to change notification settings - Fork 20
/
kod.go
48 lines (39 loc) · 831 Bytes
/
kod.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"io"
"log"
"os"
"os/exec"
"github.com/linde12/kod/editor"
)
type readwriter struct {
io.Reader
io.Writer
}
func die(format string, args ...interface{}) {
fmt.Fprintf(os.Stderr, format, args...)
os.Exit(1)
}
func main() {
configDir := os.Getenv("XI_CONFIG_DIR")
if configDir == "" {
configDir = os.Getenv("HOME") + "/.config/xi/"
}
path, err := exec.LookPath("xi-core")
if err != nil {
die("xi-core was not found in your PATH")
}
p := exec.Command(path)
stdout, _ := p.StdoutPipe()
stdin, _ := p.StdinPipe()
if err := p.Start(); err != nil {
die("error: %v", err.Error())
}
f, _ := os.OpenFile("out.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
defer f.Close()
log.SetOutput(f)
rw := readwriter{stdout, stdin}
e := editor.NewEditor(rw, configDir)
e.Start()
}