app

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package app is the yupsh REPL surface: the interactive read-eval-print loop, its built-ins, banner, and help, plus the line reader that feeds it.

It is the app tier — the CLI surface of the program. It owns no business logic: each input line is handed to the line orchestrator (internal/line), which plans a pipeline.Assembly, and the session "renders" that result by streaming it to the output writer. Built-ins (exit, help, version, clear) and I/O wiring live here; tokenizing, expansion, flag translation, and pipeline assembly do not.

Index

Constants

View Source
const Prompt = "yup> "

Prompt is printed before each input line.

View Source
const Version = "0.2.0"

Version is the REPL release. Bumped to 0.2.0 for the rework onto the gloo-foo/framework typed-stream API and the gloo-foo/cmd-* command modules.

Variables

This section is empty.

Functions

This section is empty.

Types

type LineReader

type LineReader interface {
	ReadLine() (string, error)
}

LineReader supplies successive command lines to the REPL, returning io.EOF when input is exhausted. It is the seam that lets interactive line editing and history be supplied by the terminal: *golang.org/x/term.Terminal already satisfies this interface, so the main program wires one in for TTY sessions while tests and piped input use the plain scanner reader.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is an immutable REPL instance wired to injected collaborators: a LineReader for command input, an io.Reader for pipeline stdin, output and error writers, and the line domain's Config (filesystem + home). Everything is injected so the session is fully testable with in-memory buffers and an afero.MemMapFs. Value receiver on every method — no mutation.

func New

func New(in io.Reader, out, errw io.Writer, fs afero.Fs, home expansion.Home) Session

New builds a Session that reads command lines from in (with no terminal editing) and uses in as the pipeline stdin source, writing results to out and errors to errw. File arguments and globs resolve against fs, and "~" expands to home.

func NewWithReader

func NewWithReader(reader LineReader, stdin io.Reader, out, errw io.Writer, fs afero.Fs, home expansion.Home) Session

NewWithReader builds a Session whose command lines come from an explicit LineReader (e.g. a *golang.org/x/term.Terminal for interactive history and editing), with stdin as the pipeline input source.

func (Session) Run

func (e Session) Run(ctx context.Context) error

Run executes the read-eval-print loop until end of input or an exit built-in, returning any input error other than io.EOF.

Jump to

Keyboard shortcuts

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