Build config, flags, etc

This commit is contained in:
2023-11-07 03:45:11 -05:00
parent 649d0d87f9
commit b9017499cc
9 changed files with 242 additions and 77 deletions

44
internal/flags.go Normal file
View File

@@ -0,0 +1,44 @@
package internal
import (
"flag"
"strings"
"github.com/yeslayla/godot-build-tools/logging"
)
type BuildFlags struct {
stepsRaw string
DebugLog bool
}
// Steps returns the steps to run as a slice of strings
func (f *BuildFlags) Steps() []string {
return strings.Split(f.stepsRaw, ",")
}
// HasStep returns true if the given step is in the list of steps to run
func (f *BuildFlags) HasStep(step string) bool {
steps := f.Steps()
for _, s := range steps {
if s == step {
return true
}
}
return false
}
// Parse parses the flags
func (f *BuildFlags) Parse() {
flag.Parse()
}
// NewBuildFlags creates a new BuildFlags instance
func NewBuildFlags(logger logging.Logger) *BuildFlags {
flags := &BuildFlags{}
flag.StringVar(&flags.stepsRaw, "steps", "godot-setup", "Comma-separated list of build steps to run")
flag.BoolVar(&flags.DebugLog, "verbose", false, "Enable debug logging")
return flags
}