server
Some checks failed
Build / build (push) Failing after 6m4s
Test / build (push) Failing after 6m33s

This commit is contained in:
Chuck Smith
2024-04-02 12:21:41 -04:00
parent 862119e90e
commit 4c9ec5aaaa
77 changed files with 1181 additions and 244 deletions

31
cmd/monkey-server/main.go Normal file
View File

@@ -0,0 +1,31 @@
package main
import (
"context"
"flag"
"log"
"os"
"os/signal"
)
var (
bind string
)
func init() {
flag.StringVar(&bind, "b", ":8000", "[interface]:<port> to bind to")
}
func main() {
flag.Parse()
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
svr, err := server.NewServer(server.WithBind(bind))
if err != nil {
log.Fatal(err)
}
log.Fatal(svr.Run(ctx))
}

View File

@@ -23,20 +23,26 @@ func main() {
flag.BoolVar(&trace, "T", false, "Enable VM tracing")
flag.Parse()
opts := &monkey.Options{
Debug: debug,
Trace: trace,
}
switch {
case compile:
monkey.CompileFiles(flag.Args(), debug)
monkey.CompileFiles(flag.Args(), opts)
case version:
monkey.PrintVersionInfo(os.Stdout)
case flag.NArg() > 0:
monkey.ExecFile(flag.Arg(0), flag.Args()[1:], debug, trace)
opts.Args = flag.Args()[1:]
monkey.ExecFile(flag.Arg(0), opts)
case simple:
monkey.SimpleREPL(flag.Args(), debug, trace)
monkey.SimpleREPL(flag.Args(), opts)
default:
monkey.REPL(flag.Args(), debug, trace)
monkey.REPL(flag.Args(), opts)
}
}