Documentation ¶
Index ¶
- Constants
- type Cmd
- type CmdFunc
- type Printer
- func (p *Printer) Bold(s string) string
- func (p *Printer) FprintError(w io.Writer, err error) (int, error)
- func (p *Printer) FprintHelp(w io.Writer, title string, text string) (n int, err error)
- func (p *Printer) FprintValue(w io.Writer, vs ...rt.Value) (int, error)
- func (p *Printer) FprintValueInline(w io.Writer, vs ...rt.Value) (int, error)
- func (p *Printer) SetColor(enable bool)
- func (p *Printer) SetScreenWidth(w int)
- func (p *Printer) Underline(s string) string
- func (p *Printer) WrapString(s string) string
- type Registry
- type Repl
- func (r *Repl) ClearBuffer()
- func (r *Repl) Close() error
- func (r *Repl) History() []string
- func (r *Repl) IsTerminal() bool
- func (r *Repl) Next(ctx context.Context) error
- func (r *Repl) Printer() *Printer
- func (r *Repl) PrintlnError(err error) (int, error)
- func (r *Repl) Readline() (string, error)
- func (r *Repl) Registry() *Registry
- func (r *Repl) Runtime() time.Duration
- func (r *Repl) SetColor(enable bool)
- func (r *Repl) Stdout() io.Writer
Constants ¶
const ( DefaultPrompt = "> " DefaultBufferedPrompt = ">> " )
The default prompts
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd defines a command.
func (*Cmd) Description ¶
Description returns a description of the command.
type CmdFunc ¶
CmdFunc is a function for a command. The function will be passed any text entered by the user following the command name.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer provides a way to print REPL values to a io.Writer.
func NewPrinter ¶
NewPrinter returns a new printer for the given vm.
func (*Printer) Bold ¶
Bold converts the given string to bold text, if colours are enabled. Otherwise the original string is returned.
func (*Printer) FprintError ¶
FprintError prints the error err to w. It returns the number of bytes written and any write error encountered.
func (*Printer) FprintHelp ¶
FprintHelp prints the help message to w. It returns the number of bytes written and any write error encountered.
func (*Printer) FprintValue ¶
FprintValue prints the values to w. It returns the number of bytes written and any write error encountered.
func (*Printer) FprintValueInline ¶
FprintValueInline prints the values to w. It returns the number of bytes written and any write error encountered. The values will be printed inline.
func (*Printer) SetScreenWidth ¶
SetScreenWidth sets the target display width (in characters). This will be used for line-wrapping. A width <= 0 indicates an "infinitely" wide target display.
func (*Printer) Underline ¶
Underline underlines the given string, if colours are enabled. Otherwise the original string is returned.
func (*Printer) WrapString ¶
WrapString wraps the given string to the current screen width.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a register of available commands.
func (*Registry) Get ¶
Get returns the command corresponding to the given name (excluding the leading '.').
func (*Registry) Names ¶
Names returns a slice of registered command names (excluding the leading '.'), sorted in lex order.
func (*Registry) Register ¶
Register registers the a new command with given name (excluding the leading '.'), description, and function. If a command with this name was already registered it will be replaced with the new command. Returns the new command.
func (*Registry) Run ¶
Run inspects the given line l of user input and sees whether it corresponds to a registered command. If so, the command will be run. Returns true if this line was handled by a command, along with any error returned by the command. Returns false if this line did not match a registered command.
type Repl ¶
type Repl struct {
// contains filtered or unexported fields
}
Repl is a REPL Lua interpreter.
func (*Repl) ClearBuffer ¶
func (r *Repl) ClearBuffer()
ClearBuffer clears any buffered lines of user input and updates the prompt.
func (*Repl) IsTerminal ¶
IsTerminal returns true iff standard output is a terminal.
func (*Repl) PrintlnError ¶
PrintlnError prints an error to standard output. A newline is appended to the output. It returns the number of bytes written and any write error encountered.
func (*Repl) Readline ¶
Readline reads the next line of user input. An io.EOF will be returned if the REPL should exit.