MCPcopy Index your code
hub / github.com/pterm/pterm / Srender

Method Srender

tree_printer.go:117–132  ·  view source on GitHub ↗

Srender renders the list as a string.

()

Source from the content-addressed store, hash-verified

115
116// Srender renders the list as a string.
117func (p TreePrinter) Srender() (string, error) {
118 if p.TreeStyle == nil {
119 p.TreeStyle = NewStyle()
120 }
121 if p.TextStyle == nil {
122 p.TextStyle = NewStyle()
123 }
124
125 var result strings.Builder
126 if p.Root.Text != "" {
127 result.WriteString(p.TextStyle.Sprint(p.Root.Text))
128 result.WriteByte('\n')
129 }
130 result.WriteString(walkOverTree(p.Root.Children, p, ""))
131 return result.String(), nil
132}
133
134// walkOverTree is a recursive function,
135// which analyzes a TreePrinter and connects the items with specific characters.

Callers 1

RenderMethod · 0.95

Calls 4

NewStyleFunction · 0.85
walkOverTreeFunction · 0.85
SprintMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected