More work on variants
This commit is contained in:
parent
a4fd33cbfd
commit
15b3a154ef
@ -36,7 +36,6 @@ type macro struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func processCmdMacro(macroName string, args []string, conf *config) error {
|
func processCmdMacro(macroName string, args []string, conf *config) error {
|
||||||
var found bool
|
|
||||||
for _, mn := range makeVariantNames(macroName, conf.variant) {
|
for _, mn := range makeVariantNames(macroName, conf.variant) {
|
||||||
m, ok := conf.Macros[mn]
|
m, ok := conf.Macros[mn]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -54,11 +53,7 @@ func processCmdMacro(macroName string, args []string, conf *config) error {
|
|||||||
return processCmd(margs, conf)
|
return processCmd(margs, conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
|
||||||
return fmt.Errorf("macro or variant not found: %s", macroName)
|
return fmt.Errorf("macro or variant not found: %s", macroName)
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func processCmd(params []string, conf *config) error {
|
func processCmd(params []string, conf *config) error {
|
||||||
|
17
task.go
17
task.go
@ -67,7 +67,6 @@ func (t *task) process(conf *config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func processTask(taskName string, conf *config) error {
|
func processTask(taskName string, conf *config) error {
|
||||||
var found bool
|
|
||||||
for _, tn := range makeVariantNames(taskName, conf.variant) {
|
for _, tn := range makeVariantNames(taskName, conf.variant) {
|
||||||
t, ok := conf.Tasks[tn]
|
t, ok := conf.Tasks[tn]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -78,23 +77,17 @@ func processTask(taskName string, conf *config) error {
|
|||||||
if conf.flags&flagVerbose != 0 {
|
if conf.flags&flagVerbose != 0 {
|
||||||
log.Printf("skipping processed task: %s", tn)
|
log.Printf("skipping processed task: %s", tn)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if conf.flags&flagVerbose != 0 {
|
if conf.flags&flagVerbose != 0 {
|
||||||
log.Printf("processing task: %s", tn)
|
log.Printf("processing task: %s", tn)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.handled[tn] = true
|
conf.handled[tn] = true
|
||||||
if err := t.process(conf); err != nil {
|
return t.process(conf)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
return fmt.Errorf("task or variant not found: %s", taskName)
|
return fmt.Errorf("task or variant not found: %s", taskName)
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
2
util.go
2
util.go
@ -55,7 +55,7 @@ func makeVariantNames(name, variant string) []string {
|
|||||||
|
|
||||||
names := []string{name}
|
names := []string{name}
|
||||||
if len(variant) > 0 {
|
if len(variant) > 0 {
|
||||||
names = append(names, fmt.Sprint(name, "__", variant))
|
names = []string{fmt.Sprint(name, "__", variant), name}
|
||||||
}
|
}
|
||||||
|
|
||||||
return names
|
return names
|
||||||
|
Loading…
Reference in New Issue
Block a user