debugstream

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

Package debugstream provides an interface for custom debug commands to assist in program development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommand

func AddCommand(c Command) error

AddCommand to the default command set. See ScopedCommands' AddComand.

func AddDefaultsForScope

func AddDefaultsForScope(scopeID int32, controller interface{})

AddDefaultsForScope for debugging.

func AttachToStream

func AttachToStream(ctx context.Context, input io.Reader, output io.Writer)

AttachToStream if possible to start consuming the stream and executing commands per the stored information in the ScopeCommands.

Types

type Command

type Command struct {
	Name      string
	ScopeID   int32
	Operation func([]string) string // the actual operation to execute
	Usage     string                // usage string, print when 'help' is called
	Force     bool                  // replace any existing command by this name
}

Command is a local format for performing these debug stream things.

type ScopedCommands

type ScopedCommands struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ScopedCommands for the debug stream commands. Contains a set of scopes that align with oak.Controller. Currently can only be attached to a single stream

var (
	// DefaultCommands to attach to.
	DefaultCommands *ScopedCommands
)

func NewScopedCommands

func NewScopedCommands() *ScopedCommands

NewScopedCommands creates set of standard help functions.

func (*ScopedCommands) AddCommand

func (sc *ScopedCommands) AddCommand(c Command) error

AddCommand adds a console command to call fn when '<s> <args>' is input to the console. fn will be called with args split on whitespace.

func (*ScopedCommands) AddDefaultsForScope

func (sc *ScopedCommands) AddDefaultsForScope(scopeID int32, controller window.Window)

AddDefaultsForScope for debugging.

func (*ScopedCommands) AttachToStream

func (sc *ScopedCommands) AttachToStream(ctx context.Context, input io.Reader, out io.Writer)

AttachToStream and start executing the registered commands on input to said stream. Currently a given set of scoped commands may be attached once and only once. It will stop parsing commands when the provided context is done.

func (*ScopedCommands) ClearCommand

func (sc *ScopedCommands) ClearCommand(scopeID int32, s string)

ClearCommand clears an existing debug command for scope with key: <s>

func (*ScopedCommands) CommandsInScope

func (sc *ScopedCommands) CommandsInScope(scope int32, showUsage bool) []string

CommandsInScope returns the current debug console commands as a string array

func (*ScopedCommands) RemoveScope

func (sc *ScopedCommands) RemoveScope(scope int32)

RemoveScope from the command set. Usually done on the close of a scope.

func (*ScopedCommands) ResetCommands

func (sc *ScopedCommands) ResetCommands()

ResetCommands will throw out all existing debug commands from the debug console.

func (*ScopedCommands) ResetCommandsForScope

func (sc *ScopedCommands) ResetCommandsForScope(scope int32)

ResetCommandsForScope will throw out all existing debug commands from the debug console for hte given scope.

Jump to

Keyboard shortcuts

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