liamg / loading

A collection of highly customisable loading bars for Go CLI apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⏳ loading

A collection of highly customisable loading bars for Go CLI apps.

Demo gif

Basic Usage

package main

import (
    "github.com/liamg/loading/pkg/bar"
    "time"
)

func main() {

    // create a bar
    loadingBar := bar.New()

    // set the total to 100
    loadingBar.SetTotal(100)

    // increment the bar to 100 over 10 seconds
    for i := 0; i <= 100; i++ {
        time.Sleep(time.Millisecond * 100)
        loadingBar.SetCurrent(i)
    }
}

See the examples or the gallery below for more inspiration.

Bar Anatomy

The anatomy of a bar

  1. The label, set with bar.OptionWithLabel("my label").
  2. The graphical component, set with bar.OptionWithRenderFunc(bar.RenderRainbow)
  3. The statistics component, set with bar.OptionWithStatsFuncs(bar.StatsTimeRemaining)

Example Gallery

Gallery gif

About

A collection of highly customisable loading bars for Go CLI apps.

License:MIT License


Languages

Language:Go 99.4%Language:Makefile 0.6%