MCPcopy
hub / github.com/pranshuparmar/witr / RenderContainerFallback

Function RenderContainerFallback

internal/output/docker.go:84–212  ·  view source on GitHub ↗
(w io.Writer, targetLabel string, match *model.ContainerMatch, colorEnabled bool, verbose bool)

Source from the content-addressed store, hash-verified

82}
83
84func RenderContainerFallback(w io.Writer, targetLabel string, match *model.ContainerMatch, colorEnabled bool, verbose bool) {
85 out := NewPrinter(w)
86
87 name := SanitizeTerminalLine(match.Name)
88 image := SanitizeTerminalLine(match.Image)
89 command := SanitizeTerminal(match.Command)
90 id := SanitizeTerminal(ShortContainerID(match.ID))
91 stateTag := SanitizeTerminal(containerStateTag(match))
92 networks := SanitizeTerminal(match.Networks)
93 ports := SanitizeTerminal(match.Ports)
94
95 if colorEnabled {
96 out.Printf("%sTarget%s : %s\n\n", ColorBlue, ColorReset, targetLabel)
97 } else {
98 out.Printf("Target : %s\n\n", targetLabel)
99 }
100
101 // Container line: name (id <short>) [state-or-health]
102 if colorEnabled {
103 out.Printf("%sContainer%s : %s%s%s (%sid %s%s)",
104 ColorBlue, ColorReset, ColorGreen, ansiString(name), ColorReset,
105 ColorDim, id, ColorReset)
106 } else {
107 out.Printf("Container : %s (id %s)", name, id)
108 }
109 if stateTag != "" {
110 color := ColorRed
111 if stateTag == "healthy" {
112 color = ColorGreen
113 }
114 if colorEnabled {
115 out.Printf(" %s[%s]%s", color, stateTag, ColorReset)
116 } else {
117 out.Printf(" [%s]", stateTag)
118 }
119 }
120 out.Println("")
121
122 if image != "" {
123 if colorEnabled {
124 out.Printf("%sImage%s : %s\n", ColorBlue, ColorReset, ansiString(image))
125 } else {
126 out.Printf("Image : %s\n", image)
127 }
128 }
129
130 if command != "" {
131 if colorEnabled {
132 out.Printf("%sCommand%s : %s\n", ColorBlue, ColorReset, command)
133 } else {
134 out.Printf("Command : %s\n", command)
135 }
136 }
137
138 if !match.StartedAt.IsZero() {
139 rel, dtStr := FormatStartedAt(match.StartedAt)
140 if colorEnabled {
141 out.Printf("%sStarted%s : %s (%s)\n", ColorMagenta, ColorReset, rel, dtStr)

Calls 13

PrintfMethod · 0.95
PrintlnMethod · 0.95
NewPrinterFunction · 0.85
SanitizeTerminalLineFunction · 0.85
SanitizeTerminalFunction · 0.85
ShortContainerIDFunction · 0.85
containerStateTagFunction · 0.85
ansiStringTypeAlias · 0.85
FormatStartedAtFunction · 0.85
containerChainFunction · 0.85
containerSourceLabelFunction · 0.85