More work on variants

This commit is contained in:
Alex Yatskov 2015-09-04 14:04:29 +09:00
parent a4fd33cbfd
commit 15b3a154ef
3 changed files with 10 additions and 22 deletions

View File

@ -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,13 +53,9 @@ 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 {
args := appendExpEnv(nil, params) args := appendExpEnv(nil, params)
if len(args) == 0 { if len(args) == 0 {

17
task.go
View File

@ -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
}

View File

@ -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