From 15b3a154ef5f98e16cb7bbec890f1911bfea4761 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 4 Sep 2015 14:04:29 +0900 Subject: [PATCH] More work on variants --- command.go | 7 +------ task.go | 23 ++++++++--------------- util.go | 2 +- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/command.go b/command.go index f8321c2..e8af79d 100644 --- a/command.go +++ b/command.go @@ -36,7 +36,6 @@ type macro struct { } func processCmdMacro(macroName string, args []string, conf *config) error { - var found bool for _, mn := range makeVariantNames(macroName, conf.variant) { m, ok := conf.Macros[mn] if !ok { @@ -54,11 +53,7 @@ func processCmdMacro(macroName string, args []string, conf *config) error { return processCmd(margs, conf) } - if !found { - return fmt.Errorf("macro or variant not found: %s", macroName) - } - - return nil + return fmt.Errorf("macro or variant not found: %s", macroName) } func processCmd(params []string, conf *config) error { diff --git a/task.go b/task.go index 0209c52..b920cd6 100644 --- a/task.go +++ b/task.go @@ -67,7 +67,6 @@ func (t *task) process(conf *config) error { } func processTask(taskName string, conf *config) error { - var found bool for _, tn := range makeVariantNames(taskName, conf.variant) { t, ok := conf.Tasks[tn] if !ok { @@ -78,23 +77,17 @@ func processTask(taskName string, conf *config) error { if conf.flags&flagVerbose != 0 { log.Printf("skipping processed task: %s", tn) } - } else { - if conf.flags&flagVerbose != 0 { - log.Printf("processing task: %s", tn) - } - conf.handled[tn] = true - if err := t.process(conf); err != nil { - return err - } + return nil } - found = true + if conf.flags&flagVerbose != 0 { + log.Printf("processing task: %s", tn) + } + + conf.handled[tn] = true + return t.process(conf) } - if !found { - return fmt.Errorf("task or variant not found: %s", taskName) - } - - return nil + return fmt.Errorf("task or variant not found: %s", taskName) } diff --git a/util.go b/util.go index 871746e..2d3a55e 100644 --- a/util.go +++ b/util.go @@ -55,7 +55,7 @@ func makeVariantNames(name, variant string) []string { names := []string{name} if len(variant) > 0 { - names = append(names, fmt.Sprint(name, "__", variant)) + names = []string{fmt.Sprint(name, "__", variant), name} } return names