{"id":13410034,"url":"https://github.com/vbauerster/mpb","last_synced_at":"2025-11-20T12:04:47.752Z","repository":{"id":37334587,"uuid":"76455463","full_name":"vbauerster/mpb","owner":"vbauerster","description":"multi progress bar for Go cli applications","archived":false,"fork":false,"pushed_at":"2025-04-30T06:17:28.000Z","size":7013,"stargazers_count":2394,"open_issues_count":16,"forks_count":129,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-30T06:31:44.756Z","etag":null,"topics":["actor","cli","go","progress-bar","spinner","terminal"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vbauerster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-12-14T11:56:29.000Z","updated_at":"2025-04-30T06:17:32.000Z","dependencies_parsed_at":"2022-07-12T11:55:01.782Z","dependency_job_id":"57de4bb1-cd8a-4ba3-b2c9-6a445cd09247","html_url":"https://github.com/vbauerster/mpb","commit_stats":{"total_commits":1897,"total_committers":10,"mean_commits":189.7,"dds":0.00632577754348973,"last_synced_commit":"e635a0d3f8aadaf03bcddebbd637778cab4f4a13"},"previous_names":[],"tags_count":148,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauerster%2Fmpb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauerster%2Fmpb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauerster%2Fmpb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbauerster%2Fmpb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbauerster","download_url":"https://codeload.github.com/vbauerster/mpb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252712112,"owners_count":21792264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor","cli","go","progress-bar","spinner","terminal"],"created_at":"2024-07-30T20:01:04.630Z","updated_at":"2025-11-20T12:04:47.746Z","avatar_url":"https://github.com/vbauerster.png","language":"Go","readme":"# Multi Progress Bar\n\n[![GoDoc](https://pkg.go.dev/badge/github.com/vbauerster/mpb)](https://pkg.go.dev/github.com/vbauerster/mpb/v8)\n[![Test status](https://github.com/vbauerster/mpb/actions/workflows/test.yml/badge.svg)](https://github.com/vbauerster/mpb/actions/workflows/test.yml)\n[![Lint status](https://github.com/vbauerster/mpb/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/vbauerster/mpb/actions/workflows/golangci-lint.yml)\n\n**mpb** is a Go lib for rendering progress bars in terminal applications.\n\n## Features\n\n- **Multiple Bars**: Multiple progress bars are supported\n- **Dynamic Total**: Set total while bar is running\n- **Dynamic Add/Remove**: Dynamically add or remove bars\n- **Cancellation**: Cancel whole rendering process\n- **Predefined Decorators**: Elapsed time, [ewma](https://github.com/VividCortex/ewma) based ETA, Percentage, Bytes counter\n- **Decorator's width sync**: Synchronized decorator's width among multiple bars\n\n## Usage\n\n#### [Rendering single bar](_examples/singleBar/main.go)\n\n```go\npackage main\n\nimport (\n    \"math/rand\"\n    \"time\"\n\n    \"github.com/vbauerster/mpb/v8\"\n    \"github.com/vbauerster/mpb/v8/decor\"\n)\n\nfunc main() {\n    // initialize progress container, with custom width\n    p := mpb.New(mpb.WithWidth(64))\n\n    total := 100\n    name := \"Single Bar:\"\n    // create a single bar, which will inherit container's width\n    bar := p.New(int64(total),\n        // BarFillerBuilder with custom style\n        mpb.BarStyle().Lbound(\"╢\").Filler(\"▌\").Tip(\"▌\").Padding(\"░\").Rbound(\"╟\"),\n        mpb.PrependDecorators(\n            // display our name with one space on the right\n            decor.Name(name, decor.WC{C: decor.DindentRight | decor.DextraSpace}),\n            // replace ETA decorator with \"done\" message, OnComplete event\n            decor.OnComplete(decor.AverageETA(decor.ET_STYLE_GO), \"done\"),\n        ),\n        mpb.AppendDecorators(decor.Percentage()),\n    )\n    // simulating some work\n    max := 100 * time.Millisecond\n    for i := 0; i \u003c total; i++ {\n        time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)\n        bar.Increment()\n    }\n    // wait for our bar to complete and flush\n    p.Wait()\n}\n```\n\n#### [Rendering multiple bars](_examples/multiBars/main.go)\n\n```go\n    var wg sync.WaitGroup\n    // passed wg will be accounted at p.Wait() call\n    p := mpb.New(mpb.WithWaitGroup(\u0026wg))\n    total, numBars := 100, 3\n    wg.Add(numBars)\n\n    for i := 0; i \u003c numBars; i++ {\n        name := fmt.Sprintf(\"Bar#%d:\", i)\n        bar := p.AddBar(int64(total),\n            mpb.PrependDecorators(\n                // simple name decorator\n                decor.Name(name),\n                // decor.DSyncWidth bit enables column width synchronization\n                decor.Percentage(decor.WCSyncSpace),\n            ),\n            mpb.AppendDecorators(\n                // replace ETA decorator with \"done\" message, OnComplete event\n                decor.OnComplete(\n                    // ETA decorator with ewma age of 30\n                    decor.EwmaETA(decor.ET_STYLE_GO, 30, decor.WCSyncWidth), \"done\",\n                ),\n            ),\n        )\n        // simulating some work\n        go func() {\n            defer wg.Done()\n            rng := rand.New(rand.NewSource(time.Now().UnixNano()))\n            max := 100 * time.Millisecond\n            for i := 0; i \u003c total; i++ {\n                // start variable is solely for EWMA calculation\n                // EWMA's unit of measure is an iteration's duration\n                start := time.Now()\n                time.Sleep(time.Duration(rng.Intn(10)+1) * max / 10)\n                // we need to call EwmaIncrement to fulfill ewma decorator's contract\n                bar.EwmaIncrement(time.Since(start))\n            }\n        }()\n    }\n    // wait for passed wg and for all bars to complete and flush\n    p.Wait()\n```\n\n#### [dynTotal example](_examples/dynTotal/main.go)\n\n![dynTotal](_svg/godEMrCZmJkHYH1X9dN4Nm0U7.svg)\n\n#### [complex example](_examples/complex/main.go)\n\n![complex](_svg/wHzf1M7sd7B3zVa2scBMnjqRf.svg)\n\n#### [io example](_examples/io/main.go)\n\n![io](_svg/hIpTa3A5rQz65ssiVuRJu87X6.svg)\n","funding_links":[],"categories":["命令行","Command Line","HarmonyOS","开源类库","Go","Open source library","Tools","\u003cspan id=\"命令行-command-line\"\u003e命令行 Command Line\u003c/span\u003e","Build Automation","高级控制台UI`用于构建控制台应用程序和控制台用户界面的库.`","Go 🐹","高级控制台UI"],"sub_categories":["高级控制台用户界面","Advanced Console UIs","Windows Manager","命令行","Command Line","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","高級控制台界面","高级控制台界面","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbauerster%2Fmpb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvbauerster%2Fmpb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbauerster%2Fmpb/lists"}