-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.go
66 lines (53 loc) · 1008 Bytes
/
run.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
package main
import (
"fmt"
"log"
"os"
"os/exec"
"github.com/vapourlang/vapour/cli"
"github.com/vapourlang/vapour/config"
"github.com/vapourlang/vapour/devtools"
"github.com/vapourlang/vapour/environment"
"github.com/vapourlang/vapour/lsp"
"github.com/vapourlang/vapour/r"
)
func run(code string) {
cmd := exec.Command(
"R",
"--no-save",
"--slave",
"-e",
code,
)
output, err := cmd.CombinedOutput()
if err != nil {
log.Fatal("Failed to run")
}
fmt.Println(string(output))
}
func (v *vapour) Run(args cli.CLI) {
v.config = config.ReadConfig()
environment.SetLibrary(r.LibPath())
if *args.Indir != "" {
ok := v.transpile(args)
devtools.Run(ok, args)
return
}
if *args.Infile != "" {
ok := v.transpileFile(args)
devtools.Run(ok, args)
return
}
if *args.Repl {
v.repl(os.Stdin, os.Stdout, os.Stderr)
return
}
if *args.LSP {
lsp.Run(v.config, *args.TCP, *args.Port)
return
}
if *args.Version {
fmt.Printf("v%v\n", v.version)
return
}
}