repl

package
v1.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunEnv

func RunEnv(env *lisp.LEnv, prompt, cont string, opts ...Option)

RunEnv runs a simple repl with env as a root environment.

func RunRepl

func RunRepl(prompt string, opts ...Option)

RunRepl runs a simple repl in a vanilla elps environment.

Types

type Option added in v1.16.3

type Option func(*config)

func WithBatch added in v1.16.14

func WithBatch(enabled bool) Option

WithBatch enables batch mode. The readline prompt and terminal manipulation are suppressed and raw lines are read from stdin. Batch mode auto-enables JSON output unless explicitly overridden.

func WithCompleter added in v1.24.0

func WithCompleter(ac readline.AutoCompleter) Option

WithCompleter replaces the default symbol completer with a custom readline.AutoCompleter. This allows a debug REPL to include debug command names alongside symbol completions.

func WithDoneCh added in v1.24.0

func WithDoneCh(ch <-chan struct{}) Option

WithDoneCh sets a channel that, when closed, causes RunEnv to exit cleanly. This allows an external controller (e.g., a debug REPL quit command) to stop the REPL without calling os.Exit.

func WithEval added in v1.16.14

func WithEval(expr string) Option

WithEval sets a single expression to evaluate. The REPL evaluates the expression, prints the result, and exits.

func WithEvalFunc added in v1.24.0

func WithEvalFunc(fn func(*lisp.LEnv, *lisp.LVal) *lisp.LVal) Option

WithEvalFunc replaces the default env.Eval call in the main REPL loop. This allows a debug REPL to use engine.EvalInContext instead.

func WithInterruptFunc added in v1.24.0

func WithInterruptFunc(fn func()) Option

WithInterruptFunc sets a function called when Ctrl+C is pressed. This allows a debug REPL to request a pause via the debugger engine.

func WithJSON added in v1.16.14

func WithJSON(enabled bool) Option

WithJSON enables JSON output mode. Each evaluation result is emitted as a single-line JSON object to stdout.

func WithLineHandler added in v1.24.0

func WithLineHandler(fn func(line string) bool) Option

WithLineHandler sets a function that intercepts raw input lines before they reach the parser. If it returns true, the line is consumed and not parsed as Lisp. This allows embedding debug commands (step, continue, break, etc.) in a REPL session.

func WithPromptFunc added in v1.24.0

func WithPromptFunc(fn func() (string, string)) Option

WithPromptFunc sets a function that returns the primary and continuation prompt strings dynamically. This allows a debug REPL to show state-aware prompts (e.g., "(dbg) " when paused).

func WithRootDir added in v1.20.0

func WithRootDir(dir string) Option

WithRootDir confines file access to the given directory tree. When empty, the working directory is used as the root.

func WithStderr added in v1.16.3

func WithStderr(stderr io.WriteCloser) Option

WithStderr allows overriding the output to the REPL.

func WithStdin added in v1.16.3

func WithStdin(stdin io.ReadCloser) Option

WithStdin allows overriding the input to the REPL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL