Skip to content

elliota43/simplebar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simplebar

A lightweight, single-file progress bar for Go CLI tools.

Installation

go get github.com/elliota43/simplebar

Usage

  1. The Simple Way

Just give it a total number, and it works.

package main

import (
    "time"
    "github.com/elliota43/simplebar"
)

func main() {
    bar := simplebar.New(50) // Default style: [=>-]

    for i := 0; i < 50; i++ {
        time.Sleep(50 * time.Millisecond)
        bar.Add(1)
    }
    bar.Finish()
}
  1. The Custom Way

Customize the look, width, or output destination (e.g., to a file or buffer)

bar := simplebar.New(100,
    simplebar.WithWidth(40),
    simplebar.WithPrefix("Downloading: "),
    simplebar.WithGraphChars()"█", "▒", "░")
)

Features

  • Zero Dependencies: It uses only the Go standard library and is less than 200 lines of code.
  • Thread Safe: Safe to call bar.Add() from concurrent goroutines.
  • ETA Calculation: Automatically estimates time remaining.
  • Unicode Safe: Handles multi-byte characters (like emojis/blocks) correctly without crashing.

License

MIT

About

Simple customizable and thread-safe progress bar in Go.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages