progress_bar creates a single customizable progress bar for Linux terminal.

Overview

progress_bar

Go Progress Bar

Go Go Report Card

Features

progress_bar creates a single customizable progress bar for Linux terminal.

Installation

go get -u github.com/ermanimer/progress_bar

Functions

DefaultProgressBar(totalValue float64) *ProgressBar

Creates a progress bar with default parameters and given total value.

Parameter Description
totalValue Total value of progress bar

Default parameters:

Default Parameter Value
Default Schema [{bar}][{percent}][{current}/{total}][Elapsed: {elapsed}s Remaining:{remaining}s]
Default Filled Character #
Default Blank Character .
Default Length 50

NewProgressBar(output io.Writer, schema string, filledCharacter string, blankCharacter string, length float64, totalValue float64) *ProgressBar

Creates a progress bar with default parameters and given total value.

Parameter Description
output Output of progress bar
schema Schema of progress bar
filledCharacter Filled character of progress bar
blankCharacter Blank character of progress bar
length Length of progress bar
totalValue Total value of progress bar

Schema Variables:

Schema Variable Value
{bar} Bar of progress bar
{percent} Percentage of progress bar
{current} Current value of progress bar
{total} Total value of progress bar
{elapsed} Elapsed duration
{remaining} Estimated remaining duration

Methods

Start() error

Starts progress bar.

Stop() error

Stops progress bar.

Update(value float64) error

Updates progress bar with given value and stops progress bar is total value is reached.

Parameter Description
value Current value of progress bar

Usage

Default Progress Bar:

package main

import (
	"fmt"
	"time"

	"github.com/ermanimer/progress_bar"
)

func main() {
	//create new progress bar
	pb := progress_bar.DefaultProgressBar(100)
	//start
	err := pb.Start()
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	//update
	for value := 1; value <= 100; value++ {
		time.Sleep(20 * time.Millisecond)
		err := pb.Update(float64(value))
		if err != nil {
			fmt.Println(err.Error())
			break
		}
	}
}

Terminal Output: Default Terminal Output

New Progress Bar:

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/ermanimer/progress_bar"
)

func main() {
	//create parameters
	output := os.Stdout
	schema := "({bar}) ({percent}) ({current} of {total} completed)"
	filledCharacter := "="
	blankCharacter := "-"
	var length float64 = 60
	var totalValue float64 = 80
	//create new progress bar
	pb := progress_bar.NewProgressBar(output, schema, filledCharacter, blankCharacter, length, totalValue)
	//start
	err := pb.Start()
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	//update
	for value := 1; value <= 80; value++ {
		time.Sleep(20 * time.Millisecond)
		err := pb.Update(float64(value))
		if err != nil {
			fmt.Println(err.Error())
			break
		}
	}
}

Terminal Output: New Terminal Output

New Progress Bar Colored With color:

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/ermanimer/color/v2"
	"github.com/ermanimer/progress_bar"
)

func main() {
	//create parameters
	output := os.Stdout
	//create color functions
	orange := (&color.Color{Foreground: 172}).SprintFunction()
	grey := (&color.Color{Foreground: 246}).SprintFunction()
	//create colored schema
	bar := orange("{bar}")
	percent := grey("{percent}")
	schema := fmt.Sprintf("%s %s", bar, percent)
	filledCharacter := "▆"
	blankCharacter := " "
	var length float64 = 50
	var totalValue float64 = 80
	//create new progress bar
	pb := progress_bar.NewProgressBar(output, schema, filledCharacter, blankCharacter, length, totalValue)
	//start
	err := pb.Start()
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	//update
	for value := 1; value <= 80; value++ {
		time.Sleep(20 * time.Millisecond)
		err := pb.Update(float64(value))
		if err != nil {
			fmt.Println(err.Error())
			break
		}
	}
}

Terminal Output: New Terminal Output

References

You might also like...
gif effects CLI. single binary, no dependencies. linux, osx, windows.
gif effects CLI. single binary, no dependencies. linux, osx, windows.

yeetgif Composable GIF effects CLI, with reasonable defaults. Made for custom Slack/Discord emoji :) Get it Alternative 1: go get Alternative 2: just

Procmon is a Linux reimagining of the classic Procmon tool from the Sysinternals suite of tools for Windows. Procmon provides a convenient and efficient way for Linux developers to trace the syscall activity on the system.
Procmon is a Linux reimagining of the classic Procmon tool from the Sysinternals suite of tools for Windows. Procmon provides a convenient and efficient way for Linux developers to trace the syscall activity on the system.

Process Monitor for Linux (Preview) Process Monitor (Procmon) is a Linux reimagining of the classic Procmon tool from the Sysinternals suite of tools

only for creates task and get all tasks from the db.

Todo Rest API This API only creates a task and get all tasks. Table of Contents: Getting Started Requirements Building with Docker API Endpoints and D

Highly customizable and lightweight Go CLI app framework 👌
Highly customizable and lightweight Go CLI app framework 👌

Nice 👌 Nice is a highly customizable and lightweight framework for crafting CLI apps. Nice respects idiomatic Go code and focuses to be clear, effici

The extremely customizable and themeable shell prompt.

kitch-prompt Kitch-prompt is a cross-platform tool for displaying a shell prompt, which can be extensively customized both in terms of what is shown,

Yaf - Yet another system fetch that is minimal and customizable
Yaf - Yet another system fetch that is minimal and customizable

Yaf - Yet Another Fetch [Support] [Installation] [Usage] Brief Yet Another Fetch

Utilities to prettify console output of tables, lists, progress-bars, text, etc.
Utilities to prettify console output of tables, lists, progress-bars, text, etc.

go-pretty Utilities to prettify console output of tables, lists, progress-bars, text, etc. Table Pretty-print tables into ASCII/Unicode strings.

Golang-video-screensaver - A work in progress Microsoft Windows video screensaver implemented in Go

golang-video-screensaver A work in progress Microsoft Windows video screensaver

Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.

Stonks is a terminal based stock visualizer and tracker. Installation Requirements: golang = 1.13 Manual Clone the repo Run make && make install Pack

Releases(v1.0.1)
Owner
erman imer
Software Developer
erman imer
Console progress bar for Golang

Terminal progress bar for Go Installation go get github.com/cheggaaa/pb/v3 Documentation for v1 bar available here Quick start package main import (

Sergey Cherepanov 3.3k Nov 22, 2022
multi progress bar for Go cli applications

Multi Progress Bar mpb is a Go lib for rendering progress bars in terminal applications. Features Multiple Bars: Multiple progress bars are supported

Vladimir Bauer 1.9k Nov 23, 2022
Go simple progress bar writing to output

?? progress-go Go simple progress bar writing to output ?? ABOUT Contributors: Rafał Lorenz Want to contribute ? Feel free to send pull requests! Have

Rafał Lorenz 53 Oct 30, 2022
🍫 A customisable, universally compatible terminal status bar

Shox: Terminal Status Bar A customisable terminal status bar with universal shell/terminal compatibility. Currently works on Mac/Linux. Installation N

Liam Galvin 680 Nov 21, 2022
Go (golang) package with 70+ configurable terminal spinner/progress indicators.

Spinner spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full exa

Brian Downs 1.9k Nov 15, 2022
hierarchical progress bars in terminal on steroids

Echelon - hierarchical progress in terminals Cross-platform library to organize logs in a hierarchical structure. Here is an example how it looks for

Cirrus Labs 346 Nov 26, 2022
Print day progress in your terminal

Day progress Print day progress in your terminal Install go install github.com/tsivinsky/[email protected] Usage day-progress By default, day-progre

Daniil Tsivinsky 0 Jan 10, 2022
Run your MapReduce workloads as a single binary on a single machine with multiple CPUs and high memory. Pricing of a lot of small machines vs heavy machines is the same on most cloud providers.

gomap Run your MapReduce workloads as a single binary on a single machine with multiple CPUs and high memory. Pricing of a lot of small machines vs he

null 21 Sep 16, 2022
A cli that shows a GitHub-like language usage statistics bar.

barley A cli that shows a GitHub-like language usage statistics bar. barley analyses the programming languages used in a directory and creates a used

Barış İnandıoğlu 3 Jan 8, 2022
Custom i3status bar built with Barista.

Custom i3status Customized i3status command built with Barista. Includes a Barista module for strongSwan. Install go install enr0n.net/i3status/cmd/i3

Nick Rosbrook 1 Jan 10, 2022