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

Method DisplayChangeForPush

util/ui/ui_for_push.go:26–69  ·  view source on GitHub ↗

DisplayChangeForPush will display the header and old/new value with the appropriately red/green minuses and pluses.

(header string, stringTypePadding int, hiddenValue bool, originalValue interface{}, newValue interface{})

Source from the content-addressed store, hash-verified

24// DisplayChangeForPush will display the header and old/new value with the
25// appropriately red/green minuses and pluses.
26func (ui *UI) DisplayChangeForPush(header string, stringTypePadding int, hiddenValue bool, originalValue interface{}, newValue interface{}) error {
27 ui.terminalLock.Lock()
28 defer ui.terminalLock.Unlock()
29
30 originalType := reflect.ValueOf(originalValue).Type()
31 newType := reflect.ValueOf(newValue).Type()
32 if originalType != newType {
33 return ErrValueMismatch
34 }
35
36 offset := strings.Repeat(" ", stringTypePadding)
37
38 switch oVal := originalValue.(type) {
39 case int:
40 nVal := newValue.(int)
41 ui.displayDiffForInt(offset, header, oVal, nVal)
42 case types.NullInt:
43 nVal := newValue.(types.NullInt)
44 ui.displayDiffForNullInt(offset, header, oVal, nVal)
45 case uint64:
46 nVal := newValue.(uint64)
47 ui.displayDiffForUint64(offset, header, oVal, nVal)
48 case string:
49 nVal := newValue.(string)
50 ui.displayDiffForString(offset, header, hiddenValue, oVal, nVal)
51 case []string:
52 nVal := newValue.([]string)
53 if len(oVal) == 0 && len(nVal) == 0 {
54 return nil
55 }
56
57 ui.displayDiffForStrings(offset, header, oVal, nVal)
58 case map[string]string:
59 nVal := newValue.(map[string]string)
60 if len(oVal) == 0 && len(nVal) == 0 {
61 return nil
62 }
63
64 ui.displayDiffForMapStringString(offset, header, oVal, nVal)
65 default:
66 panic(fmt.Sprintf("diff display does not have case for '%s'", header))
67 }
68 return nil
69}
70
71// DisplayChangesForPush will display the set of changes via
72// DisplayChangeForPush in the order given.

Callers 2

DisplayChangesForPushMethod · 0.95

Calls 7

displayDiffForIntMethod · 0.95
displayDiffForNullIntMethod · 0.95
displayDiffForUint64Method · 0.95
displayDiffForStringMethod · 0.95
displayDiffForStringsMethod · 0.95
TypeMethod · 0.65

Tested by

no test coverage detected