got the reporter doing the right thing without colour
parent
c45e5cc948
commit
f80ca76952
@ -1,2 +1,2 @@
|
||||
# pretty-diff-reporter
|
||||
Pretty reporter for cmp.Diff with colourized output support
|
||||
# multilinediff
|
||||
Pretty multiline diff tool and library with a custom reporter for cmp.Diff.
|
||||
|
@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/RageCage64/multilinediff"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := `a
|
||||
b
|
||||
c
|
||||
diff`
|
||||
b := `a
|
||||
b
|
||||
c
|
||||
f
|
||||
f
|
||||
f`
|
||||
|
||||
fmt.Println(multilinediff.MultilineDiff(a, b, "\n"))
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("not ready yet")
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package multilinediff
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
)
|
||||
|
||||
func MultilineDiff(a, b, lineSep string) string {
|
||||
reporter := Reporter{
|
||||
LineSep: lineSep,
|
||||
}
|
||||
cmp.Diff(
|
||||
a, b,
|
||||
cmpopts.AcyclicTransformer("multiline", func(s string) []string {
|
||||
return strings.Split(s, lineSep)
|
||||
}),
|
||||
cmp.Reporter(&reporter),
|
||||
)
|
||||
return reporter.String()
|
||||
}
|
Loading…
Reference in New Issue