rline

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 4 Imported by: 11

Documentation

Overview

Package rline provides a readline implementation for usql.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInterrupt is the interrupt error.
	ErrInterrupt = readline.ErrInterrupt
	// ErrPasswordNotAvailable is the password not available error.
	ErrPasswordNotAvailable = errors.New("password not available")
)

Functions

This section is empty.

Types

type IO

type IO interface {
	// Next returns the next line of runes (excluding '\n') from the input.
	Next() ([]rune, error)
	// Close closes the IO.
	Close() error
	// Stdout is the IO's standard out.
	Stdout() io.Writer
	// Stderr is the IO's standard error out.
	Stderr() io.Writer
	// Interactive determines if the IO is an interactive terminal.
	Interactive() bool
	// Cygwin determines if the IO is a Cygwin interactive terminal.
	Cygwin() bool
	// Prompt sets the prompt for the next interactive line read.
	Prompt(string)
	// Completer sets the auto-completer.
	Completer(readline.AutoCompleter)
	// Save saves a line of history.
	Save(string) error
	// Password prompts for a password.
	Password(string) (string, error)
	// SetOutput sets the output filter func.
	SetOutput(func(string) string)
}

IO is the common input/output interface.

func New

func New(interactive, cygwin, forceNonInteractive bool, out, histfile string) (IO, error)

New creates a new readline input/output handler.

type Rline

type Rline struct {
	Inst *readline.Instance
	N    func() ([]rune, error)
	C    func() error
	Out  io.Writer
	Err  io.Writer
	Int  bool
	Cyg  bool
	P    func(string)
	A    func(readline.AutoCompleter)
	S    func(string) error
	Pw   func(string) (string, error)
}

Rline provides a type compatible with the IO interface.

func (*Rline) Close

func (l *Rline) Close() error

Close closes the IO.

func (*Rline) Completer added in v0.9.0

func (l *Rline) Completer(a readline.AutoCompleter)

Completer sets the auto-completer.

func (*Rline) Cygwin

func (l *Rline) Cygwin() bool

Cygwin determines if the IO is a Cygwin interactive terminal.

func (*Rline) Interactive

func (l *Rline) Interactive() bool

Interactive determines if the IO is an interactive terminal.

func (*Rline) Next

func (l *Rline) Next() ([]rune, error)

Next returns the next line of runes (excluding '\n') from the input.

func (*Rline) Password

func (l *Rline) Password(prompt string) (string, error)

Password prompts for a password.

func (*Rline) Prompt

func (l *Rline) Prompt(s string)

Prompt sets the prompt for the next interactive line read.

func (*Rline) Save

func (l *Rline) Save(s string) error

Save saves a line of history.

func (*Rline) SetOutput added in v0.6.0

func (l *Rline) SetOutput(f func(string) string)

SetOutput sets the output format func.

func (*Rline) Stderr

func (l *Rline) Stderr() io.Writer

Stderr is the IO's standard error out.

func (*Rline) Stdout

func (l *Rline) Stdout() io.Writer

Stdout is the IO's standard out.

Jump to

Keyboard shortcuts

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