script

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: GPL-3.0, GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package script allows the debugger to record and replay debugging scripts. In this package we refer to this as scribing and rescribing.

Scripts can of course be handwritten and be rescribed as though they had been scribed by the debugger. In this instance however, there is a risk that there will be errors - invalid commands will not be written to the script file by the Scribe type. On Rescribing, invalid commands will attempt to be replayed and the appropriate error message printed to the terminal. Comment lines begin with the # symbol.

Scripts can be run when scribing a new script. The action of running the script will be recorded in the new script.

The Rescribe type satisfies the terminal.Input and is used as a source for the debugger packages input loop.

Index

Constants

View Source
const (
	ScriptEnd = "end of script (%s)"
)

Sentinal error returned when Rescribe.TermRead() reaches the expected end of the script.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rescribe

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

Rescribe represents an previously scribed script. The type implements the terminal.UserRead interface.

func RescribeScript

func RescribeScript(scriptfile string) (*Rescribe, error)

RescribeScript is the preferred method of initialisation for the Rescribe type.

func (*Rescribe) IsInteractive

func (scr *Rescribe) IsInteractive() bool

IsInteractive implements the terminal.Input interface.

func (*Rescribe) TermRead

func (scr *Rescribe) TermRead(buffer []byte, _ terminal.Prompt, _ *terminal.ReadEvents) (int, error)

TermRead implements the terminal.Input interface.

func (*Rescribe) TermReadCheck

func (scr *Rescribe) TermReadCheck() bool

TermReadCheck implements the terminal.Input interface.

type Scribe

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

Scribe can be used again after a start()/end() cycle. isWriting() can be used to detect if a script is currently being captured but it is safe not to do because most functions silently fail if there is no current active session.

func (*Scribe) Commit

func (scr *Scribe) Commit() error

Commit most recent calls to WriteInput() and WriteOutput().

func (*Scribe) EndPlayback

func (scr *Scribe) EndPlayback() error

EndPlayback indicates that a replayed script has finished.

func (*Scribe) EndSession

func (scr *Scribe) EndSession() (rerr error)

EndSession the current scribe session.

func (Scribe) IsActive

func (scr Scribe) IsActive() bool

IsActive returns true if a script is currently being capture.

func (*Scribe) Rollback

func (scr *Scribe) Rollback()

Rollback undoes calls to WriteInput() and WriteOutput since last Commit().

func (*Scribe) StartPlayback

func (scr *Scribe) StartPlayback() error

StartPlayback indicates that a replayed script has begun.

func (*Scribe) StartSession

func (scr *Scribe) StartSession(scriptfile string) error

StartSession a new script.

func (*Scribe) WriteInput

func (scr *Scribe) WriteInput(command string) error

WriteInput writes user-input to the open script file.

Jump to

Keyboard shortcuts

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