Skip to content

safe-waters/pbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ci Go Report Card Go Reference

What is this?

A simple terminal progress bar

How to use

package main

import (
	"time"

	"github.com/safe-waters/pbar"
)

func main() {
	const n = 3

	p, err := pbar.New(n)
	if err != nil {
		// n must be > 0
		panic(err)
	}

	p.Start()
	for i := 0; i < n; i++ {
		p.Increment(1)
		time.Sleep(time.Second * 1)
	}
	p.End()
}

// Output (one line, overtime):
//
// 0 / 3: |--------------------------------------------------| 0.00% Complete
// 1 / 3: |████████████████----------------------------------| 33.33% Complete
// 2 / 3: |█████████████████████████████████-----------------| 66.67% Complete
// 3 / 3: |██████████████████████████████████████████████████| 100.00% Complete

About

A simple terminal progress bar

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages