-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (47 loc) · 1.05 KB
/
main.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
49
50
51
52
53
54
55
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"os/exec"
"github.com/jantb/olive/editor"
)
import _ "net/http/pprof"
import _ "net/http"
type readwriter struct {
io.Reader
io.Writer
}
func die(format string, args ...interface{}) {
fmt.Fprintf(os.Stderr, format, args...)
os.Exit(1)
}
func main() {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()
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\n" +
"Install it from https://github.com/xi-editor/xi-editor/")
}
p := exec.Command(path)
stdout, _ := p.StdoutPipe()
stdin, _ := p.StdinPipe()
if err := p.Start(); err != nil {
die("error: %v", err.Error())
}
f, _ := os.OpenFile(os.Getenv("HOME")+"/.olive.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
defer f.Close()
log.SetOutput(f)
rw := readwriter{stdout, stdin}
editor := editor.NewEdit(rw, configDir)
editor.Start()
editor.Quit()
}