Files
monkey/options.go
Chuck Smith 4c9ec5aaaa
Some checks failed
Build / build (push) Failing after 6m4s
Test / build (push) Failing after 6m33s
server
2024-04-02 12:21:41 -04:00

35 lines
549 B
Go

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),
}
}