github.com/rliebz/tusk@v0.6.5-0.20240416035353-dd5a98e9a5fb/runner/context.go (about) 1 package runner 2 3 import "github.com/rliebz/tusk/ui" 4 5 // Context contains contextual information about a run. 6 type Context struct { 7 // Dir is the directory that defines the config file, which is the relative 8 // directory for all command execution. 9 Dir string 10 11 // Logger is responsible for logging actions as they occur. It is required to 12 // be defined for a Context. 13 Logger *ui.Logger 14 15 // Interpreter specifies how a command is meant to be executed. 16 Interpreter []string 17 18 taskStack []*Task 19 } 20 21 // PushTask adds a sub-task to the task stack. 22 func (r *Context) PushTask(t *Task) { 23 r.taskStack = append(r.taskStack, t) 24 } 25 26 // TaskNames returns the list of task names in the stack, in order. Private 27 // tasks are filtered out. 28 func (r *Context) TaskNames() []string { 29 output := make([]string, 0, len(r.taskStack)) 30 for _, t := range r.taskStack { 31 if !t.Private { 32 output = append(output, t.Name) 33 } 34 } 35 return output 36 }