MCPcopy Create free account
hub / github.com/containerd/nerdctl / Ellipsis

Function Ellipsis

pkg/formatter/formatter.go:95–113  ·  view source on GitHub ↗
(str string, maxDisplayWidth int)

Source from the content-addressed store, hash-verified

93}
94
95func Ellipsis(str string, maxDisplayWidth int) string {
96 if maxDisplayWidth <= 0 {
97 return ""
98 }
99
100 runes := []rune(str)
101 lenStr := len(runes)
102 if maxDisplayWidth == 1 {
103 if lenStr <= maxDisplayWidth {
104 return str
105 }
106 return string(runes[0])
107 }
108
109 if lenStr <= maxDisplayWidth {
110 return str
111 }
112 return string(runes[:maxDisplayWidth-1]) + "…"
113}
114
115func formatRange(startHost, endHost, startContainer, endContainer int32) string {
116 if startHost == endHost && startContainer == endContainer {

Callers 3

truncateDescriptionFunction · 0.92
TestEllipsisFunction · 0.85
InspectContainerCommandFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEllipsisFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…