MCPcopy
hub / github.com/pterm/pterm / Fprint

Function Fprint

print.go:105–146  ·  view source on GitHub ↗

Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

(writer io.Writer, a ...any)

Source from the content-addressed store, hash-verified

103// Spaces are added between operands when neither is a string.
104// It returns the number of bytes written and any write error encountered.
105func Fprint(writer io.Writer, a ...any) {
106 if !Output {
107 return
108 }
109
110 var ret string
111 var printed bool
112
113 for _, bar := range ActiveProgressBarPrinters {
114 if bar.IsActive && (bar.Writer == writer || bar.Writer == os.Stderr) {
115 ret += sClearLine()
116 ret += Sprinto(a...)
117 printed = true
118 }
119 }
120
121 for _, spinner := range activeSpinnerPrinters {
122 if spinner.IsActive && (spinner.Writer == writer || spinner.Writer == os.Stderr) {
123 ret += sClearLine()
124
125 ret += Sprinto(a...)
126 printed = true
127 }
128 }
129
130 if !printed {
131 ret = color.Sprint(Sprint(a...))
132 }
133
134 if writer != nil {
135 color.Fprint(writer, Sprint(ret))
136 } else {
137 color.Print(Sprint(ret))
138 }
139
140 // Refresh all progressbars in case they were overwritten previously. Reference: #302
141 for _, bar := range ActiveProgressBarPrinters {
142 if bar.IsActive {
143 bar.UpdateTitle(bar.Title)
144 }
145 }
146}
147
148// Fprintln formats using the default formats for its operands and writes to w.
149// Spaces are always added between operands and a newline is appended.

Callers 15

TestFprintFunction · 0.92
PrintMethod · 0.85
PrintlnMethod · 0.85
PrintfMethod · 0.85
PrintflnMethod · 0.85
PrintMethod · 0.85
PrintlnMethod · 0.85
PrintfMethod · 0.85
PrintflnMethod · 0.85
PrintMethod · 0.85
PrintlnMethod · 0.85
PrintfMethod · 0.85

Calls 6

sClearLineFunction · 0.85
SprintoFunction · 0.85
SprintFunction · 0.85
UpdateTitleMethod · 0.80
SprintMethod · 0.65
PrintMethod · 0.65

Tested by 1

TestFprintFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…