Documentation ¶
Overview ¶
Package repl provides a REPL implementation and options to expose Sabre features through a read-eval-print-loop.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrMapper ¶
ErrMapper should map a custom Input error to nil to indicate error that should be ignored by REPL, EOF to signal end of REPL session and any other error to indicate a irrecoverable failure.
type Input ¶
Input implementation is used by REPL to read user-input. See WithInput() REPL option to configure an Input.
type NamespacedScope ¶
type NamespacedScope interface {
CurrentNS() string
}
NamespacedScope can be implemented by sabre.Scope implementations to allow namespace based isolation (similar to Clojure). REPL will call CurrentNS() method to get the current Namespace and display it as part of input prompt.
type Option ¶
type Option func(repl *REPL)
Option implementations can be provided to New() to configure the REPL during initialization.
func WithBanner ¶
WithBanner sets the REPL's banner which is displayed once when the REPL starts.
func WithInput ¶
WithInput sets the REPL's input stream. `nil` defaults to bufio.Scanner backed by os.Stdin
func WithOutput ¶
WithOutput sets the REPL's output stream.`nil` defaults to stdout.
func WithPrinter ¶ added in v0.3.1
WithPrinter sets the print function for the REPL. It is useful for customizing how different types should be rendered into human-readable character streams.
func WithPrompts ¶
WithPrompts sets the prompt to be displayed when waiting for user input in the REPL.
func WithReaderFactory ¶
func WithReaderFactory(factory ReaderFactory) Option
WithReaderFactory can be used set factory function for initializing sabre Reader. This is useful when you want REPL to use custom reader instance.
type REPL ¶
type REPL struct {
// contains filtered or unexported fields
}
REPL implements a read-eval-print loop for a generic Runtime.
func New ¶
New returns a new instance of REPL with given sabre Scope. Option values can be used to configure REPL input, output etc.
type ReaderFactory ¶
ReaderFactory should return an instance of reader when called. This might be called repeatedly. See WithReaderFactory()
type ReaderFactoryFunc ¶
ReaderFactoryFunc implements ReaderFactory using a function value.