diff --git a/cmd/diff.go b/cmd/diff.go index cb39dd884..1aa2f309b 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -66,12 +66,13 @@ either by name or by their hash`, case "delta": displayFormat = "delta" case "detail": - displayFormat = "plusMinusColor" + displayFormat = "plusMinus" } } result, err := datasetDiffer.MapDiffsToString(diffs, displayFormat) ExitIfErr(err) - fmt.Println(result) + + printDiffs(result) }, } diff --git a/cmd/print.go b/cmd/print.go index e7da9ae4b..cdcb67499 100644 --- a/cmd/print.go +++ b/cmd/print.go @@ -219,3 +219,39 @@ func inputText(message, defaultText string) string { return input } + +/* + white := color.New(color.FgWhite).SprintFunc() + cyan := color.New(color.FgCyan).SprintFunc() + blue := color.New(color.FgBlue).SprintFunc() + fmt.Printf("%s:\t%s\n\t%s\n", cyan(i), white(r.Dataset.Transform.Data), blue(r.Path)) +*/ +func printDiffs(diffText string) { + green := color.New(color.FgGreen).SprintFunc() + red := color.New(color.FgRed).SprintFunc() + lines := strings.Split(diffText, "\n") + for _, line := range lines { + if len(line) >= 3 { + if line[:2] == "+ " || line[:2] == "++" { + fmt.Printf("%s\n", green(line)) + } else if line[:2] == "- " || line[:2] == "--" { + fmt.Printf("%s\n", red(line)) + } else { + fmt.Printf("%s\n", line) + } + } else { + fmt.Printf("%s\n", line) + } + } + // output := "" + // for _, line := range lines { + // if len(line) >= 3 && (line[:2] == "+ " || line[:2] == "++") { + // output += fmt.Sprintf("🎾%s\n", green(line)) + // } else if len(line) >= 3 && (line[:2] == "- " || line[:2] == "--") { + // output += fmt.Sprintf("🏓%s\n", red(line)) + // } else { + // output += fmt.Sprintf("%s\n", line) + // } + // } + // fmt.Printf("%s", output) +}