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

34
options.go Normal file
View File

@@ -0,0 +1,34 @@
package monkey
import (
"context"
"io"
"monkey/internal/vm"
)
type Options struct {
Debug bool
Trace bool
Args []string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Exit func(int)
}
func (opts Options) ToVMOptions() []vm.Option {
ctx := context.New(
context.WithArgs(opts.Args),
context.WithStdin(opts.Stdin),
context.WithStdout(opts.Stdout),
context.WithStderr(opts.Stderr),
context.WithExit(opts.Exit),
)
return []vm.Option{
vm.WithDebug(opts.Debug),
vm.WithDebug(opts.Trace),
vm.WithContext(ctx),
}
}