diff --git a/pkg/cli/evaluate.go b/pkg/cli/evaluate.go index e8d1fe3..ce09ec3 100644 --- a/pkg/cli/evaluate.go +++ b/pkg/cli/evaluate.go @@ -26,6 +26,8 @@ var evaluateChangeInCmd = &cobra.Command{ output := fetchRequiredStringFlag(cmd, "output") logsPath := fetchRequiredStringFlag(cmd, "logs") + fmt.Printf("Evaluating change_in expressions in %s.\n\n", input) + logs.Open(logsPath) logs.SetCurrentPipelineFilePath(input) diff --git a/pkg/pipelines/model.go b/pkg/pipelines/model.go index a1cd2e4..124062f 100644 --- a/pkg/pipelines/model.go +++ b/pkg/pipelines/model.go @@ -2,6 +2,7 @@ package pipelines import ( "encoding/json" + "fmt" "time" gabs "github.com/Jeffail/gabs/v2" @@ -29,7 +30,13 @@ func (p *Pipeline) EvaluateChangeIns() error { return err } - for index := range list { + p.displayFoundWhenExpressions(list) + + fmt.Println("Evaluating when expressions.\n") + + for index, condition := range list { + fmt.Printf("%03d) %s\n", index+1, condition.Expression) + err := list[index].Eval() if err != nil { return err @@ -87,6 +94,17 @@ func (p *Pipeline) ExtractWhenConditions() ([]when.WhenExpression, error) { return extractor.Parse() } +func (p *Pipeline) displayFoundWhenExpressions(list []when.WhenExpression) { + fmt.Printf("Found when expressions at %d locations:\n\n", len(list)) + + for index, condition := range list { + fmt.Printf("%03d) Location: %+v\n", index+1, condition.Path) + fmt.Printf(" File: %s\n", condition.YamlPath) + fmt.Printf(" Expression: %s\n", condition.Expression) + fmt.Println() + } +} + func (p *Pipeline) ToJSON() ([]byte, error) { return json.Marshal(p.raw) }