tinsel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueueInput

func QueueInput(newline bool)

Signal the stdin pipe to queue the next input. Should be called right before reading from stdin.

Optionally print a newline to stdout to mimic pressing enter in a terminal.

Note: if the pipe is not open, this function does nothing.

Types

type StdinPipe

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

StdinPipe is a test helper for inputting stdin. The primary use case is to submit program input typically collected from the console.

func OpenStdinPipe

func OpenStdinPipe(bufSize int) StdinPipe

Create a new StdinPipe. After calling, stdin will read input from the pipe until Close is called.

'bufSize' defines the size of the input buffer. Ensure the size is large enough to prevent stalling.

func (StdinPipe) Close

func (p StdinPipe) Close()

Close the pipe and restore stdin. The pipe can no longer be read from or written to.

func (StdinPipe) Submit

func (p StdinPipe) Submit(input ...any)

Submit new input to the buffer. If the buffer is full, the execution will stall until room is made.

type StdoutPipe

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

StdoutPipe is a test helper for capturing stdout. The primary use case is to test program output typically printed to the console.

func OpenStdoutPipe

func OpenStdoutPipe() StdoutPipe

Create a new StdoutPipe. After calling, stdout will write output to the pipe until Close is called.

func (StdoutPipe) Close

func (p StdoutPipe) Close()

Close the pipe and restore stdout. The pipe can no longer be written to or read from.

func (StdoutPipe) ReadLine

func (p StdoutPipe) ReadLine() string

Read from the pipe until a newline is encountered.

If there are no more newlines in the pipe, the program stalls until one is written.

func (StdoutPipe) ReadLines

func (p StdoutPipe) ReadLines(n int) []string

Read 'n' lines from the pipe and return as a slice. Lines are separated by the newline character.

If there are no more newlines in the pipe, the program stalls until one is written.

Jump to

Keyboard shortcuts

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