-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoublu.go
77 lines (64 loc) · 1.53 KB
/
goublu.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// GoUblu github.com/jwoehr/goublu
// goublu launches and serves as a better-than-Java console for
// https://github.com/jwoehr/ublu Ublu, a Java-coded domain-specific language
// for remote programming of IBM midrange and mainframe systems.
// Neither this project nor Ublu are associated with IBM.
package main
import (
"fmt"
"log"
"os"
"github.com/jroimartin/gocui"
)
var CompileDate string
var GoubluVersion string
func main() {
if len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--version") {
fmt.Println("Goublu version", GoubluVersion, "compiled", CompileDate)
os.Exit(0)
}
args := NewArgs(os.Args[:])
options := NewOptions()
options.FromPropStrings(args.Goubluargs)
ublu := NewUblu(args, options)
if ublu != nil {
history := NewHistory()
// cogui
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Panicln(err)
} else {
g.Mouse = true
}
um := NewUbluManager(ublu, g, options, history)
g.SetManager(um)
g.Cursor = true
um.CompileDate = CompileDate
um.Version = GoubluVersion
// Deliver Ublu's stdout
go func() {
for {
text, _ := ublu.OutReader.ReadString('\n')
um.Ubluout(g, text)
}
}()
// Deliver Ublu's stderr
go func() {
for {
text, _ := ublu.ErrReader.ReadString('\n')
um.Ubluout(g, text)
}
}()
// Run the Gui
go func() {
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
log.Panicln(err)
}
}()
ublu.Run()
g.Close()
ublu.Close()
fmt.Println("Ublu has exited.")
}
fmt.Println("Goodbye from Goublu!")
}