@@ -92,6 +92,12 @@ type Format struct {
9292 aName string
9393 // bName is an optional custom name for B in the diff.
9494 bName string
95+ // deleteTitle is an optional custom name when titling the diff section
96+ // with delete paths.
97+ deleteTitle string
98+ // deleteDesc is an optional custom description when describing a
99+ // delete path in the diff.
100+ deleteDesc string
95101}
96102
97103func formatJSONValue (value interface {}) interface {} {
@@ -115,11 +121,17 @@ func (diff StructuredDiff) Format(f Format) string {
115121 if f .bName == "" {
116122 f .bName = "B"
117123 }
124+ if f .deleteTitle == "" {
125+ f .deleteDesc = "deletes"
126+ }
127+ if f .deleteDesc == "" {
128+ f .deleteTitle = "deleted only in %s"
129+ }
118130 b .WriteString (fmt .Sprintf ("%s(-%s, +%s):\n " , f .title , f .aName , f .bName ))
119131
120132 deleteDiff := diff .DeleteDiff .format (f )
121133 if deleteDiff != "" {
122- b .WriteString ("-------- deletes --------\n " )
134+ b .WriteString (fmt . Sprintf ( "-------- %s --------\n " , f . deleteTitle ) )
123135 b .WriteString (deleteDiff )
124136 b .WriteString ("-------- updates --------\n " )
125137 }
@@ -177,7 +189,15 @@ func (diff DeleteDiff) format(f Format) string {
177189 }
178190 sort .Strings (paths )
179191 for _ , path := range paths {
180- b .WriteString (fmt .Sprintf ("%c %s: deleted\n " , symbol , path ))
192+ b .WriteString (fmt .Sprintf ("%c %s: " + f .deleteDesc , symbol , path ))
193+ switch symbol {
194+ case '-' :
195+ b .WriteString (fmt .Sprintf (" only in %s\n " , f .aName ))
196+ case '+' :
197+ b .WriteString (fmt .Sprintf (" only in %s\n " , f .bName ))
198+ default :
199+ b .WriteString ("\n " )
200+ }
181201 }
182202 }
183203
0 commit comments