在终端应用上展示进度条的Go库:uiprogress
一个Go库用于在在终端应用上展示进度条。它提供了一套强大的功能并且可以使用简单的界面进行自定义。
Progress bars improve readability for terminal applications with long outputs by providing a concise feedback loop.
特性
- Multiple Bars: uiprogress can render multiple progress bars that can be tracked concurrently
- Dynamic Addition: Add additional progress bars any time, even after the progress tracking has started
- Prepend and Append Functions: Append or prepend completion percent and time elapsed to the progress bars
- Custom Decorator Functions: Add custom functions around the bar along with helper functions
用法
To start listening for progress bars, calluiprogress.Start()and add a progress bar usinguiprogress.AddBar(total). Update the progress usingbar.Set(n). Full source code for the below example is available at example/simple/simple.go
uiprogress.Start() // start rendering bar := uiprogress.AddBar(100) // Add a new bar // optionally, append and prepend completion and elapsed time bar.AppendCompleted() bar.PrependElapsed() for i := 1; i <= bar.Total; i++ { bar.Set(i) time.Sleep(time.Millisecond * 10) }
This will render the below in the terminal
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!