MCPcopy
hub / github.com/vbauerster/mpb

github.com/vbauerster/mpb @v8.12.1 sqlite

repository ↗ · DeepWiki ↗ · release v8.12.1 ↗
466 symbols 1,655 edges 79 files 170 documented · 36%
README

Multi Progress Bar

GoDoc Test status Lint status

mpb is a Go lib for rendering progress bars in terminal applications.

Features

  • Multiple Bars: Multiple progress bars are supported
  • Dynamic Total: Set total while bar is running
  • Dynamic Add/Remove: Dynamically add or remove bars
  • Cancellation: Cancel whole rendering process
  • Predefined Decorators: Elapsed time, ewma based ETA, Percentage, Bytes counter
  • Decorator's width sync: Synchronized decorator's width among multiple bars

Usage

Rendering single bar

package main

import (
    "math/rand"
    "time"

    "github.com/vbauerster/mpb/v8"
    "github.com/vbauerster/mpb/v8/decor"
)

func main() {
    // initialize progress container, with custom width
    p := mpb.New(mpb.WithWidth(64))

    total := 100
    name := "Single Bar:"
    // create a single bar, which will inherit container's width
    bar := p.New(int64(total),
        // BarFillerBuilder with custom style
        mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟"),
        mpb.PrependDecorators(
            // display our name with one space on the right
            decor.Name(name, decor.WC{C: decor.DindentRight | decor.DextraSpace}),
            // replace ETA decorator with "done" message, OnComplete event
            decor.OnComplete(decor.AverageETA(decor.ET_STYLE_GO), "done"),
        ),
        mpb.AppendDecorators(decor.Percentage()),
    )
    // simulating some work
    max := 100 * time.Millisecond
    for range total {
        time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
        bar.Increment()
    }
    // wait for our bar to complete and flush
    p.Wait()
}

Rendering multiple bars

    var wg sync.WaitGroup
    // passed wg will be accounted at p.Wait() call
    p := mpb.New(mpb.WithWaitGroup(&wg))
    total, numBars := 100, 3
    wg.Add(numBars)

    for i := range numBars {
        name := fmt.Sprintf("Bar#%d:", i)
        bar := p.AddBar(int64(total),
            mpb.PrependDecorators(
                // simple name decorator
                decor.Name(name),
                // decor.DSyncWidth bit enables column width synchronization
                decor.Percentage(decor.WCSyncSpace),
            ),
            mpb.AppendDecorators(
                // replace ETA decorator with "done" message, OnComplete event
                decor.OnComplete(
                    // ETA decorator with ewma age of 30
                    decor.EwmaETA(decor.ET_STYLE_GO, 30, decor.WCSyncWidth), "done",
                ),
            ),
        )
        // simulating some work
        go func() {
            defer wg.Done()
            rng := rand.New(rand.NewSource(time.Now().UnixNano()))
            max := 100 * time.Millisecond
            for range total {
                // start variable is solely for EWMA calculation
                // EWMA's unit of measure is an iteration's duration
                start := time.Now()
                time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10)
                // we need to call EwmaIncrement to fulfill ewma decorator's contract
                bar.EwmaIncrement(time.Since(start))
            }
        }()
    }
    // wait for passed wg and for all bars to complete and flush
    p.Wait()

dynTotal example

dynTotal

queueBar example

queueBar

io example

io

Extension points exported contracts — how you extend this code

Decorator (Interface)
Decorator interface. Most of the time there is no need to implement this interface manually, as decor package already pr [11 …
decor/decorator.go
BarFiller (Interface)
BarFiller interface. Bar (without decorators) renders itself by calling BarFiller's Fill method. [2 implementers]
bar_filler.go
ContainerOption (FuncType)
ContainerOption is a func option to alter default behavior of a bar container. Container term refers to a Progress struc
container_option.go
BarOption (FuncType)
BarOption is a func option to alter default behavior of a bar.
bar_option.go
TimeNormalizer (Interface)
TimeNormalizer interface. Implementers could be passed into MovingAverageETA, in order to affect i.e. normalize its outp
decor/eta.go
Wrapper (Interface)
Wrapper interface. If you're implementing custom Decorator by wrapping a built-in one, it is necessary to implement this [5 …
decor/decorator.go
BarFillerBuilder (Interface)
BarFillerBuilder interface. Default implementations are: BarStyle() SpinnerStyle() NopStyle() [2 implementers]
bar_filler.go
TimeNormalizerFunc (FuncType)
TimeNormalizerFunc is function type adapter to convert function into TimeNormalizer.
decor/eta.go

Core symbols most depended-on inside this repo

Build
called by 178
bar_filler.go
BarStyle
called by 174
bar_filler_bar.go
New
called by 101
progress.go
Wait
called by 68
bar.go
TipOnComplete
called by 56
bar_filler_bar.go
Error
called by 49
_examples/suppressBar/main.go
AddBar
called by 43
progress.go
Percentage
called by 39
decor/percentage.go

Shape

Function 215
Method 170
Struct 53
TypeAlias 11
Interface 10
FuncType 7

Languages

Go100%

Modules by API surface

bar.go40 symbols
bar_filler_bar.go26 symbols
progress.go23 symbols
decor/decorator.go23 symbols
bar_option.go21 symbols
decor/eta.go18 symbols
container_option.go17 symbols
decor/counters.go16 symbols
proxywriter_test.go15 symbols
heap_manager.go14 symbols
decor/speed.go14 symbols
barbench_test.go14 symbols

Dependencies from manifests, versioned

github.com/VividCortex/ewmav1.2.0 · 1×
github.com/acarl005/stripansiv0.0.0-2018011610285 · 1×
github.com/clipperhouse/uax29/v2v2.7.0 · 1×
github.com/google/pprofv0.0.0-2026050701375 · 1×
github.com/mattn/go-colorablev0.1.14 · 1×
github.com/mattn/go-isattyv0.0.22 · 1×
github.com/mattn/go-runewidthv0.0.23 · 1×
github.com/pkg/profilev1.7.0 · 1×
golang.org/x/modv0.24.0 · 1×

For agents

$ claude mcp add mpb \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact