Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,6 @@
/* get_system_command_output.wren */
class Command {
foreign static output(name, param) // the code for this is provided by Go
}
System.print(Command.output("ls", "-ls"))

View file

@ -0,0 +1,39 @@
/* get_system_command_output.go */
package main
import (
wren "github.com/crazyinfin8/WrenGo"
"log"
"os"
"os/exec"
)
type any = interface{}
func getCommandOutput(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.Stderr = os.Stderr
bytes, err := cmd.Output()
if err != nil {
log.Fatal(err)
}
return string(bytes), nil
}
func main() {
vm := wren.NewVM()
fileName := "get_system_command_output.wren"
methodMap := wren.MethodMap{"static output(_,_)": getCommandOutput}
classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)}
module := wren.NewModule(classMap)
vm.SetModule(fileName, module)
vm.InterpretFile(fileName)
vm.Free()
}