Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pcj/mobyprogress
The progress bar from the docker/moby project, repackaged as a standalone library
https://github.com/pcj/mobyprogress
Last synced: about 1 month ago
JSON representation
The progress bar from the docker/moby project, repackaged as a standalone library
- Host: GitHub
- URL: https://github.com/pcj/mobyprogress
- Owner: pcj
- License: apache-2.0
- Created: 2022-11-13T18:47:37.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-14T20:33:23.000Z (about 2 years ago)
- Last Synced: 2024-06-21T05:58:38.130Z (5 months ago)
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mobyprogress
[![ci](https://github.com/pcj/mobyprogress/actions/workflows/ci.yaml/badge.svg?branch=master&event=push)](https://github.com/pcj/mobyprogress/actions/workflows/ci.yaml)
[![godoc](https://godoc.org/github.com/pcj/mobyprogress?status.svg)](https://godoc.org/github.com/pcj/mobyprogress)The progress bar from the docker/moby project, repackaged as a standalone library.
Have you ever wanted a progress bar for your golang-based CLI tool only to find that
the library either does not work on all platforms or does not have multibar support?
Me too! I've always liked the `docker` cli progress bar so I went ahead and broke
it out into it's own library.Note that since I am not the original author of this code I won't accept new features;
this code is considered "complete".# Installation
```
go get github.com/pcj/mobyprogress@latest
```# Usage
Create a `mobyprogess.Output` instance over an `io.Writer`:
```go
out := mobyprogress.NewOut(os.Stdout)progress := mobyprogress.NewProgressOutput(out)
```Then, send progress updates to the output:
```go
progress.WriteProgress(progress.Progress{
ID: "some.tar.gz",
Action: "downloading",
Total: int64(bytesTotal),
Current: int64(bytesSent),
Units: "bytes",
})
```The `progress.ID` field is used as the key to identify the progress bar to update.