MCPcopy Create free account
hub / github.com/auth0/auth0-cli / printColorDiff

Function printColorDiff

internal/cli/actions.go:725–754  ·  view source on GitHub ↗
(code1, code2 string, fromVersion, toVersion int)

Source from the content-addressed store, hash-verified

723}
724
725func printColorDiff(code1, code2 string, fromVersion, toVersion int) {
726 diff := difflib.UnifiedDiff{
727 A: difflib.SplitLines(code1),
728 B: difflib.SplitLines(code2),
729 FromFile: fmt.Sprintf("v%d", fromVersion),
730 ToFile: fmt.Sprintf("v%d", toVersion),
731 Context: 3,
732 }
733 text, _ := difflib.GetUnifiedDiffString(diff)
734
735 if text == "" {
736 fmt.Printf("No differences found between v%d and v%d - the code is identical\n", fromVersion, toVersion)
737 return
738 }
739
740 fmt.Printf("Comparing v%d → v%d:\n\n", fromVersion, toVersion)
741
742 for _, line := range difflib.SplitLines(text) {
743 switch {
744 case len(line) > 0 && line[0] == '+':
745 fmt.Print(ansi.Green(line)) // Green for additions.
746 case len(line) > 0 && line[0] == '-':
747 fmt.Print(ansi.Red(line)) // Red for deletions.
748 case len(line) > 0 && line[0] == '@':
749 fmt.Print(ansi.Cyan(line)) // Cyan for hunk headers.
750 default:
751 fmt.Println(line) // Default color.
752 }
753 }
754}
755
756func pickTwoVersions(versions []*management.ActionVersion) (int, int, error) {
757 if len(versions) < 2 {

Callers 1

diffActionCmdFunction · 0.85

Calls 3

GreenFunction · 0.92
RedFunction · 0.92
CyanFunction · 0.92

Tested by

no test coverage detected