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{})
| 24 | // DisplayChangeForPush will display the header and old/new value with the |
| 25 | // appropriately red/green minuses and pluses. |
| 26 | func (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. |
no test coverage detected