server
This commit is contained in:
34
options.go
Normal file
34
options.go
Normal 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),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user