MCPcopy Index your code
hub / github.com/cloudfoundry/cli / displayDiffForMapStringString

Method displayDiffForMapStringString

util/ui/ui_for_push.go:110–147  ·  view source on GitHub ↗
(offset string, header string, oldMap map[string]string, newMap map[string]string)

Source from the content-addressed store, hash-verified

108}
109
110func (ui UI) displayDiffForMapStringString(offset string, header string, oldMap map[string]string, newMap map[string]string) {
111 var oldKeys []string
112 for key := range oldMap {
113 oldKeys = append(oldKeys, key)
114 }
115
116 var newKeys []string
117 for key := range newMap {
118 newKeys = append(newKeys, key)
119 }
120
121 sortedKeys := sortedUniqueArray(oldKeys, newKeys)
122
123 fmt.Fprintf(ui.Out, " %s\n", ui.TranslateText(header))
124 for _, key := range sortedKeys {
125 newVal, ok := newMap[key]
126 if !ok {
127 formattedOld := fmt.Sprintf("- %s", key)
128 fmt.Fprintln(ui.Out, ui.modifyColor(formattedOld, color.New(color.FgRed)))
129 continue
130 }
131 oldVal, ok := oldMap[key]
132 if !ok {
133 formattedNew := fmt.Sprintf("+ %s", key)
134 fmt.Fprintln(ui.Out, ui.modifyColor(formattedNew, color.New(color.FgGreen)))
135 continue
136 }
137
138 if oldVal == newVal {
139 fmt.Fprintf(ui.Out, " %s\n", key)
140 } else {
141 formattedOld := fmt.Sprintf("- %s", key)
142 fmt.Fprintln(ui.Out, ui.modifyColor(formattedOld, color.New(color.FgRed)))
143 formattedNew := fmt.Sprintf("+ %s", key)
144 fmt.Fprintln(ui.Out, ui.modifyColor(formattedNew, color.New(color.FgGreen)))
145 }
146 }
147}
148
149func (ui UI) displayDiffForNullInt(offset string, header string, oldValue types.NullInt, newValue types.NullInt) {
150 if oldValue != newValue {

Callers 1

DisplayChangeForPushMethod · 0.95

Calls 3

TranslateTextMethod · 0.95
modifyColorMethod · 0.95
sortedUniqueArrayFunction · 0.85

Tested by

no test coverage detected