-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
121 lines (105 loc) · 3.04 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package main
import (
"C"
"github.com/sol-eng/wbi/cmd"
"github.com/sol-eng/wbi/internal/config"
"github.com/sol-eng/wbi/internal/languages"
"github.com/sol-eng/wbi/internal/prodrivers"
"github.com/sol-eng/wbi/internal/quarto"
"github.com/sol-eng/wbi/internal/workbench"
"os"
"strings"
)
// https://goreleaser.com/cookbooks/using-main.version
var (
version string = "dev"
commit string = "none"
date string = "unknown"
)
func main() {
cmd.Execute(version, os.Args[1:])
}
func OSSwitch(osGo string) config.OperatingSystem {
var osType config.OperatingSystem
switch osGo {
case "U20":
osType = config.Ubuntu20
case "U22":
osType = config.Ubuntu22
case "RH7":
osType = config.Redhat7
case "RH8":
osType = config.Redhat8
case "RH9":
osType = config.Redhat9
default:
osType = config.Redhat8
}
return osType
}
//export rversions
func rversions() *C.char {
result, _ := languages.RetrieveValidRVersions()
return C.CString(strings.Join(result, " "))
}
//export rurls
func rurls(os *C.char, rVersion *C.char) *C.char {
osGo := C.GoString(os)
rVersionGo := C.GoString(rVersion)
osType := OSSwitch(osGo)
installerInfo, _ := languages.PopulateInstallerInfo("r", rVersionGo, osType)
//fmt.Println(installerInfo.URL)
return C.CString(installerInfo.URL)
}
//export pythonversions
func pythonversions(os *C.char) *C.char {
osGo := C.GoString(os)
osType := OSSwitch(osGo)
result, _ := languages.RetrieveValidPythonVersions(osType)
return C.CString(strings.Join(result, " "))
}
//export pythonurls
func pythonurls(os *C.char, pythonVersion *C.char) *C.char {
osGo := C.GoString(os)
pythonVersionGo := C.GoString(pythonVersion)
osType := OSSwitch(osGo)
installerInfo, _ := languages.PopulateInstallerInfo("python", pythonVersionGo, osType)
//fmt.Println(installerInfo.URL)
return C.CString(installerInfo.URL)
}
//export quartoversions
func quartoversions() *C.char {
result, _ := quarto.RetrieveValidQuartoVersions()
return C.CString(strings.Join(result, " "))
}
//export quartourls
func quartourls(os *C.char, quartoVersion *C.char) *C.char {
osGo := C.GoString(os)
quartoVersionGo := C.GoString(quartoVersion)
osType := OSSwitch(osGo)
quartoURL := quarto.GenerateQuartoInstallURL(quartoVersionGo, osType)
//fmt.Println(installerInfo.URL)
return C.CString(quartoURL)
}
//export workbenchurl
func workbenchurl(os *C.char) (*C.char, *C.char) {
osGo := C.GoString(os)
osType := OSSwitch(osGo)
// Retrieve JSON data
rstudio, _ := workbench.RetrieveWorkbenchInstallerInfo()
// Retrieve installer info
installerInfo, _ := rstudio.GetInstallerInfo(osType)
//fmt.Println(installerInfo.URL)
return C.CString(installerInfo.Version), C.CString(installerInfo.URL)
}
//export driverurl
func driverurl(os *C.char) (*C.char, *C.char) {
osGo := C.GoString(os)
osType := OSSwitch(osGo)
// Retrieve JSON data
rstudio, _ := prodrivers.RetrieveProDriversInstallerInfo()
// Retrieve installer info
installerInfo, _ := rstudio.GetInstallerInfo(osType)
//fmt.Println(installerInfo.URL)
return C.CString(installerInfo.Version), C.CString(installerInfo.URL)
}