iowrapper

package
v0.0.0-...-85367c3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SharedReader

type SharedReader struct {
	Ch chan []byte // Send all data read from source input to this channel.
	// contains filtered or unexported fields
}

SharedReader implements the io.Reader interface: https://pkg.go.dev/io#Reader, which allows us to provide it as the input reader for bubbletea: e.g tea.NewProgram(m, tea.WithInput(stdinReader{})

At any given time, SharedReader can be in one of two modes:

1: bubbletea mode: In this mode, we say we are "detached" from stdin,
   all input is read and processed by the bubbletea library.

2: normal mode: In this mode, cased-cli consumes stdin input normally.

func New

func New(input io.Reader) *SharedReader

New creates a new SharedReader instance which consumes input from the io.Reader object given, e.g. os.Stdin.

func (*SharedReader) Attach

func (r *SharedReader) Attach()

Attach switches input mode from bubbletea to normal

func (*SharedReader) Detach

func (r *SharedReader) Detach()

Detach switches input mode from normal to bubbletea.

func (*SharedReader) IsDetached

func (r *SharedReader) IsDetached() bool

func (*SharedReader) Read

func (r *SharedReader) Read(p []byte) (n int, err error)

func (*SharedReader) ReadLoop

func (r *SharedReader) ReadLoop()

ReadLoop forward data read to the inputChan channel. This blocks, it's meant to be running in a separate goroutine.

Jump to

Keyboard shortcuts

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