MCPcopy Index your code
hub / github.com/rclone/rclone / printProgress

Function printProgress

cmd/progress.go:79–119  ·  view source on GitHub ↗

printProgress prints the progress with an optional log

(logMessage string)

Source from the content-addressed store, hash-verified

77
78// printProgress prints the progress with an optional log
79func printProgress(logMessage string) {
80 operations.StdoutMutex.Lock()
81 defer operations.StdoutMutex.Unlock()
82
83 var buf bytes.Buffer
84 w, _ := terminal.GetSize()
85 stats := strings.TrimSpace(accounting.GlobalStats().String())
86 logMessage = strings.TrimSpace(logMessage)
87
88 out := func(s string) {
89 buf.WriteString(s)
90 }
91
92 if logMessage != "" {
93 out("\n")
94 out(terminal.MoveUp)
95 }
96 // Move to the start of the block we wrote erasing all the previous lines
97 for range nlines - 1 {
98 out(terminal.EraseLine)
99 out(terminal.MoveUp)
100 }
101 out(terminal.EraseLine)
102 out(terminal.MoveToStartOfLine)
103 if logMessage != "" {
104 out(terminal.EraseLine)
105 out(logMessage + "\n")
106 }
107 fixedLines := strings.Split(stats, "\n")
108 nlines = len(fixedLines)
109 for i, line := range fixedLines {
110 if len(line) > w {
111 line = line[:w]
112 }
113 out(line)
114 if i != nlines-1 {
115 out("\n")
116 }
117 }
118 terminal.Write(buf.Bytes())
119}

Callers 1

startProgressFunction · 0.85

Calls 9

GetSizeFunction · 0.92
GlobalStatsFunction · 0.92
WriteFunction · 0.92
outFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
StringMethod · 0.65
WriteStringMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…