Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -1,8 +0,0 @@
|
|||
/* Execute_a_system_command.wren */
|
||||
class Command {
|
||||
foreign static exec(name, param) // the code for this is provided by Go
|
||||
}
|
||||
|
||||
Command.exec("ls", "-lt")
|
||||
System.print()
|
||||
Command.exec("dir", "")
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/* Execute_a_system_command.go*/
|
||||
package main
|
||||
|
||||
import (
|
||||
wren "github.com/crazyinfin8/WrenGo"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type any = interface{}
|
||||
|
||||
func execCommand(vm *wren.VM, parameters []any) (any, error) {
|
||||
name := parameters[1].(string)
|
||||
param := parameters[2].(string)
|
||||
var cmd *exec.Cmd
|
||||
if param != "" {
|
||||
cmd = exec.Command(name, param)
|
||||
} else {
|
||||
cmd = exec.Command(name)
|
||||
}
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
vm := wren.NewVM()
|
||||
fileName := "Execute_a_system_command.wren"
|
||||
methodMap := wren.MethodMap{"static exec(_,_)": execCommand}
|
||||
classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)}
|
||||
module := wren.NewModule(classMap)
|
||||
vm.SetModule(fileName, module)
|
||||
vm.InterpretFile(fileName)
|
||||
vm.Free()
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import "os" for Process
|
||||
|
||||
Process.exec("ls", ["-lt"])
|
||||
System.print()
|
||||
Process.exec("dir")
|
||||
Loading…
Add table
Add a link
Reference in a new issue