commandtree

package
v0.0.0-...-deba36d Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SpinnerCharacters = []rune("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")

Functions

func ConsoleUI

func ConsoleUI(root CommandNode) error

func ConsoleUIInterupt

func ConsoleUIInterupt(fn func())

func NewLogFuncWriter

func NewLogFuncWriter(prefix string, log func(format string, args ...interface{})) io.Writer

func OSExec

func OSExec(owner *Command, dir string, logPrefix string, program string, args ...string) error

func OSExecAllToStdOut

func OSExecAllToStdOut(owner *Command, dir string, logPrefix string, program string, args ...string) error

func SingleCommandUI

func SingleCommandUI(c *Command)

func StreamCall

func StreamCall(command CommandNode, attachTo CommandNode, threads int, input io.Reader, errorReader io.Reader, output io.Writer, log func(s string)) error

func StreamReceive

func StreamReceive(input io.Reader, output io.Writer) error

Types

type Command

type Command struct {
	ID      string
	Caption string
	State   CommandState

	LogEvent func(evt *MonitorEvent)
	LogArray []*LogEntry

	Children      []CommandNode
	RemoteCommand bool
	// contains filtered or unexported fields
}

func (*Command) Add

func (c *Command) Add(caption string, cmd CommandNode) CommandNode

func (*Command) AnyError

func (c *Command) AnyError() bool

func (*Command) AsCommand

func (c *Command) AsCommand() *Command

func (*Command) Err

func (c *Command) Err(err error)

Err appends an error to the command execution log

func (*Command) Errf

func (c *Command) Errf(message string, args ...interface{})

Errf appends a formatted error message to the commands execution log

func (*Command) GetResult

func (c *Command) GetResult() interface{}

func (*Command) Logf

func (c *Command) Logf(message string, args ...interface{})

Logf appends a formatted message to the commands execution log

func (*Command) SetProgress

func (c *Command) SetProgress(p float64)

func (*Command) SetResult

func (c *Command) SetResult(value interface{})

type CommandNode

type CommandNode interface {
	Execute()
	AsCommand() *Command
}

func NewBashCommands

func NewBashCommands(dir string, timeTakenFormat string, logprefix string, commands ...string) CommandNode

func NewExecCommand

func NewExecCommand(dir string, timeTakenFormat string, logprefix string, program string, args ...string) CommandNode

func NewFuncCommand

func NewFuncCommand(execute func(cmd *Command)) CommandNode

type CommandState

type CommandState int
const (
	CommandStateReady CommandState = iota
	CommandStateRunning
	CommandStatePaused
	CommandStateCompleted
)

type LogEntry

type LogEntry struct {
	Message string
	Error   error
	Time    time.Time
}

type MonitorEvent

type MonitorEvent struct {
	EventType monitorEventType
	CommandID string
	ParentID  string
	State     CommandState
	Caption   string
	LogEntry  *LogEntry
	Result    interface{}
}

type RootCommand

type RootCommand struct {
	Command
}

func NewRootCommand

func NewRootCommand(caption string) *RootCommand

func (*RootCommand) Execute

func (c *RootCommand) Execute()

type Runner

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

func NewRunner

func NewRunner(root CommandNode, threads int) *Runner

func (*Runner) Run

func (r *Runner) Run(monitor chan *MonitorEvent) bool

Jump to

Keyboard shortcuts

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