MCPcopy
hub / github.com/docker/compose / extractLines

Function extractLines

cmd/display/tty_test.go:62–74  ·  view source on GitHub ↗

extractLines parses the output buffer and returns lines without ANSI control sequences

(buf *bytes.Buffer)

Source from the content-addressed store, hash-verified

60
61// extractLines parses the output buffer and returns lines without ANSI control sequences
62func extractLines(buf *bytes.Buffer) []string {
63 content := buf.String()
64 // Split by newline
65 rawLines := strings.Split(content, "\n")
66 var lines []string
67 for _, line := range rawLines {
68 // Skip empty lines and lines that are just ANSI codes
69 if lenAnsi(line) > 0 {
70 lines = append(lines, line)
71 }
72 }
73 return lines
74}
75
76func TestPrintWithDimensions_LinesFitTerminalWidth(t *testing.T) {
77 testCases := []struct {

Calls 2

lenAnsiFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected