@@ -0,0 +1,45 @@
1+package main
2+
3+import (
4+ "fmt"
5+ "os"
6+ "os/exec"
7+ "syscall"
8+ "github.com/replit/prybar/utils"
9+)
10+
11+
12+func Execute(config *utils.Config) {
13+ path, err := exec.LookPath("scala")
14+
15+ if err != nil {
16+ panic(err)
17+ }
18+
19+ env := os.Environ()
20+ args := []string{"scala"}
21+
22+ if config.Quiet {
23+ args = append(args, "-Dscala.shell.welcome=")
24+ }
25+
26+ if config.Code != "" {
27+ args = append(args, "-e", config.Code)
28+ }
29+
30+ if config.Exp != "" {
31+ printStatement := fmt.Sprintf("print(%s)", config.Exp)
32+ args = append(args, "-e", printStatement)
33+ }
34+
35+ if config.Ps1 != "" {
36+ args = append(args, "-Dscala.shell.prompt=%n" + config.Ps1)
37+ }
38+
39+ if config.Args != nil && len(config.Args) > 0 {
40+ args = append(args, "-i")
41+ args = append(args, config.Args...)
42+ }
43+
44+ syscall.Exec(path, args, env)
45+}