https://github.com/nathan-fiscaletti/progresscli-go
A progress bar implementation in Golang
https://github.com/nathan-fiscaletti/progresscli-go
command-line gui progress-bar
Last synced: over 1 year ago
JSON representation
A progress bar implementation in Golang
- Host: GitHub
- URL: https://github.com/nathan-fiscaletti/progresscli-go
- Owner: nathan-fiscaletti
- License: mit
- Created: 2020-08-16T20:39:05.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-16T23:32:44.000Z (almost 6 years ago)
- Last Synced: 2025-01-19T19:20:32.087Z (over 1 year ago)
- Topics: command-line, gui, progress-bar
- Language: Go
- Homepage:
- Size: 56.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Progress CLI
[](https://goreportcard.com/report/github.com/nathan-fiscaletti/progresscli-go)
[](https://godoc.org/github.com/nathan-fiscaletti/progresscli-go)
Progress CLI gives you the ability to add customized progress bars to your CLI application.
## Installation
```sh
$ go get github.com/nathan-fiscaletti/progresscli-go
```
## Basic Usage
```go
package main
import(
"time"
"github.com/nathan-fiscaletti/progresscli-go"
)
func main() {
bar := progresscli.New()
bar.Show()
for i := float64(0); i < bar.GetMax(); i++ {
bar.Increment(1)
time.Sleep(time.Millisecond * 25)
}
}
```
## Custom Styles
You can implement your own Style for the Progress bar.
There are several components that make up the progress bar.

The style that would make up the above progress bar would look like this:
```go
bar.SetLabel("Loading")
bar.SetStyle(progresscli.Style{
OpenChar: "[",
CloseChar: "]",
DoneChar: "*",
NotDoneChar: "-",
InProgressChar: "/",
PercentageColor: "",
})
```
You can customize the characters used and the bar will automatically adjust it's size accordingly. This includes using multiple characters for different components of the progress bar.
**There are several built in progress bar styles that you can make use of.**

## Controlling the Progress Bar
You can set the progress for the progress bar using either the `SetValue(value)` or the `Increment(amount)` functions of the Progress Bar instance.
- `SetValue(value)` will directly set the value of the progress bar.
- `Increment(amount)` will add `amount` to the current value of the progress bar.