console

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LibraryName = "scriptling.console"

Variables

This section is empty.

Functions

func NewLibrary

func NewLibrary() *object.Library

NewLibrary creates the scriptling.console library.

func Register

func Register(registrar interface{ RegisterLibrary(*object.Library) })

Register registers the console library with a scriptling instance.

func SetBackend

func SetBackend(b ConsoleBackend)

SetBackend registers a custom backend (e.g. TUI). Call before running scripts.

Types

type ConsoleBackend

type ConsoleBackend interface {
	Input(prompt string, env *object.Environment) (string, error)
	Print(text string, env *object.Environment)
	PrintAs(label, text string, env *object.Environment)
	StreamStart()
	StreamStartAs(label string)
	StreamChunk(chunk string)
	StreamEnd()
	SpinnerStart(text string)
	SpinnerStop()
	SetProgress(label string, pct float64)
	SetLabels(user, assistant, system string)
	SetStatus(left, right string)
	SetStatusLeft(left string)
	SetStatusRight(right string)
	RegisterCommand(name, description string, handler func(args string))
	RemoveCommand(name string)
	OnSubmit(fn func(ctx context.Context, text string))
	OnEscape(fn func())
	ClearOutput()
	Run() error
}

ConsoleBackend is the interface scriptling.console calls through. The CLI registers a TUI-backed implementation via SetBackend().

func GetBackend

func GetBackend() ConsoleBackend

GetBackend returns the current backend.

Jump to

Keyboard shortcuts

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