Skip to content

Commit e624a55

Browse files
authored
Update webview.go
1 parent 38d2d8f commit e624a55

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

contrib/ui/mesh-ui/webview.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/RiV-chain/RiV-mesh/src/admin"
2121
)
2222

23-
var riv_ctrl_path []string
23+
var riv_ctrl_path string
2424

2525
func main() {
2626
debug := true
@@ -155,21 +155,21 @@ func get_user_home_path() string {
155155
}
156156
}
157157

158-
func get_ctl_path() []string{
158+
func get_ctl_path() string{
159159
if runtime.GOOS == "windows" {
160160
program_path := "programfiles"
161161
path, exists := os.LookupEnv(program_path)
162162
if exists {
163163
fmt.Println("Program path: %s", path)
164164
ctl_path := fmt.Sprintf("%s\\RiV-mesh\\meshctl.exe", path)
165-
return []string{"cmd.exe", "/c", ctl_path}
165+
return ctl_path
166166
} else {
167167
fmt.Println("could not find Program Files path")
168-
return []string{}
168+
return ""
169169
}
170170
} else {
171171
ctl_path := fmt.Sprintf("/usr/local/bin/meshctl")
172-
return []string{"bash", "-c", ctl_path}
172+
return ctl_path
173173
}
174174
}
175175

@@ -184,10 +184,8 @@ func run(w webview.WebView){
184184
}
185185

186186
func run_command(command string) []byte{
187-
cmd_array := make([]string, 3)
188-
copy(cmd_array,riv_ctrl_path)
189-
cmd_array[2] = cmd_array[2]+" -json "+command
190-
cmd := exec.Command(cmd_array[0], cmd_array[1:]...)
187+
args := []string{"-json", command}
188+
cmd := exec.Command(riv_ctrl_path, args...)
191189
out, err := cmd.CombinedOutput()
192190
if err != nil {
193191
//log.Fatalf("cmd.Run() failed with %s\n", err)
@@ -197,10 +195,8 @@ func run_command(command string) []byte{
197195
}
198196

199197
func run_command_with_arg(command string, arg string) []byte{
200-
cmd_array := make([]string, 3)
201-
copy(cmd_array,riv_ctrl_path)
202-
cmd_array[2] = cmd_array[2]+" -json "+command+" "+arg
203-
cmd := exec.Command(cmd_array[0], cmd_array[1:]...)
198+
args := []string{"-json", command, arg}
199+
cmd := exec.Command(riv_ctrl_path, args...)
204200
out, err := cmd.CombinedOutput()
205201
if err != nil {
206202
//log.Fatalf("command failed: %s\n", riv_ctrl_path+" "+strings.Join(args, " "))

0 commit comments

Comments
 (0)