35 lines
549 B
Go
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),
|
|
}
|
|
}
|