pbuild/internal/runner/profile.go

42 lines
938 B
Go
Raw Normal View History

2023-08-15 18:41:11 +08:00
package runner
import (
"fmt"
"strings"
"time"
)
// A Profile defines what to run when invoked on the target directory.
type Profile struct {
Name string // Name of the profile.
ID string // ID of the profile.
Commands []string // Commands to run on the profile.
Environ map[string]string // Environment variables
Output []string // List of globs to match output files.
OutputDir string // The globs will be matched in this relative directory.
}
type LogEntry struct {
Time time.Time
Text string
OutFd int // 0(manual) 1(stdout) 2(stderr)
}
type Logs []LogEntry
func (logs Logs) String() string {
var buf strings.Builder
for _, log := range logs {
switch log.OutFd {
case 0:
fmt.Fprintf(&buf, "%s %s\n", log.Time.Format("15:04:05"), log.Text)
case 1, 2:
fmt.Fprintf(&buf, "%s %s\n", log.Time.Format("15:04:05"), log.Text)
}
}
return buf.String()
}