• Stars
    star
    257
  • Rank 158,728 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple and extensible status bar to pretty display of Golang program's progress

barely report

Dead simple but yet extensible status bar for displaying interactive progress for the shell-based tools, written in Go-lang.

barely-example

Example

package main

import (
	"fmt"
	"math/rand"
	"os"
	"sync"
	"sync/atomic"
	"time"

	"github.com/reconquest/barely"
	"github.com/reconquest/loreley"
)

func main() {
	format, err := loreley.CompileWithReset(
		` {bg 2}{fg 15}{bold} {.Mode} `+
			`{bg 253}{fg 0} `+
			`{if .Updated}{fg 70}{end}{.Done}{fg 0}/{.Total} `,
		nil,
	)
	if err != nil {
		panic(err)
	}

	var (
		bar = barely.NewStatusBar(format.Template)
		wg  = sync.WaitGroup{}

		status = &struct {
			Mode  string
			Total int
			Done  int64

			Updated int64
		}{
			Mode:  "PROCESSING",
			Total: 100,
		}
	)

	bar.SetStatus(status)
	bar.Render(os.Stderr)

	for i := 1; i <= status.Total; i++ {
		wg.Add(1)

		go func(i int) {
			sleep := time.Duration(rand.Intn(i)) * time.Millisecond * 300
			time.Sleep(sleep)

			atomic.AddInt64(&status.Done, 1)
			atomic.AddInt64(&status.Updated, 1)

			if i%10 == 0 {
				bar.Clear(os.Stderr)
				fmt.Printf("go-routine %d done (%s sleep)\n", i, sleep)
			}

			bar.Render(os.Stderr)

			wg.Done()

			<-time.After(time.Millisecond * 500)
			atomic.AddInt64(&status.Updated, -1)
			bar.Render(os.Stderr)
		}(i)
	}

	wg.Wait()

	bar.Clear(os.Stderr)
}

More Repositories

1

orgalorg

Parallel SSH commands runner and file synchronization tool
Go
888
star
2

shadowd

Secure login distribution service
Go
361
star
3

shdoc

Documentation generator for shell scripts (bash, sh, zsh). Javadoc for shell scripts.
Awk
263
star
4

tubekit

🧪 kubectl alternative with quick context switching, kubectl on steroids
Go
203
star
5

hierr-go

Hierarchical errors reporting done right in Golang
Go
73
star
6

vim-autosurround

Automatically insert pairs (brackets, quotes) where they are supposed to be
Python
54
star
7

atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
Go
45
star
8

loreley

Simple and extensible colorizer for programs' output
Go
39
star
9

goava

The research project based on the draft design of Go Generics
33
star
10

gunter

Simple configuration system
Go
27
star
11

vim-pythonx

Python libraries for making coding in vim easier
Python
26
star
12

import.bash

Golang-like import statement in bash
Shell
25
star
13

tests.sh

Simple test library for integration and functional testing of daemons, services and command line tools
Shell
21
star
14

coproc.bash

Missing parallel routines (coprocesses) in bash
Shell
16
star
15

karma-go

Everything has a reason.
Go
15
star
16

archiso-zfs

archlinux iso with zfs (archzfs archiso)
Shell
14
star
17

shadowc

Client for the secure login distribution service.
Go
13
star
18

resources-go

Cache that always has a value. Cache that automatically loads values. Refresh caches automatically in background.
Go
11
star
19

rex

Ultimate XKB bindings for insane typing productivity
8
star
20

zeus

zfs backup tool
Go
7
star
21

guntalina

Create and execute command list basing on list of modified/created files and list of rules
Go
7
star
22

opts.bash

Missing very simple option parser for bash
Shell
6
star
23

marvex

Tiling terminal multiplexor
Go
6
star
24

args

Simple CLI parser for bash
Shell
6
star
25

atlassian-pull-request-labels

Pull Request Labels Bitbucket Add-On
Java
5
star
26

taild

Go
5
star
27

executil-go

just do what golang authors can't
Go
5
star
28

bitbucket-external-hook

A cli for enabling/configuring hooks in Atlassian Bitbucket
Go
5
star
29

colorgful

Simple and extensible colorizer for lorg, Go-lang logger
Go
5
star
30

treetrunks

Go
3
star
31

sould

Service for mirroring git repositories
Go
3
star
32

go-test.bash

Collect code coverage while running Go-lang binary
Shell
3
star
33

bmo

The missing tool for parsing structured text, like logs
Go
3
star
34

snippets

marvelous snippets which will change your life
Vim Snippet
3
star
35

health-go

Go
2
star
36

fresh

2
star
37

classes.bash

Classes. In bash.
Shell
2
star
38

ser-go

Go
2
star
39

test-runner.bash

Integrations Test Runner for tests.sh
Shell
2
star
40

snobs

Go
2
star
41

sign-go

Simplest Go signals-per-callback handler.
Go
2
star
42

progress.bash

Shell
2
star
43

cog

Structured key-value logger without breaking order of fields. 🔧
Go
2
star
44

monk

Based on philosophical papers
Go
2
star
45

workers-go

Go
2
star
46

snake-runner

Snake Runner — The Job Runner for Snake CI
Go
2
star
47

threadpool-go

Go
1
star
48

regexputil-go

Extract subexp names in golang regexp
Go
1
star
49

types.bash

Type checking functions for bash scripts
Shell
1
star
50

charts

Smarty
1
star
51

mrdig

Makefile
1
star
52

when

Go
1
star
53

highlight

easy interface to bash (terminal) escape codes highlighting
Shell
1
star
54

ssh-test.bash

Library for accessing remote nodes by ssh, commonly used in tests
Shell
1
star
55

tmux.bash

Shell
1
star
56

cli

Go
1
star
57

stats-go

Go
1
star
58

vim-colorscheme

Vim Script
1
star
59

xcsyncd

C
1
star
60

pipe

Go
1
star
61

uuid-go

Go
1
star
62

orgalorg-bottlebreaker

Sync tool for orgalorg
Go
1
star
63

bash-get

go get inspired bash get
Shell
1
star
64

zen-go

Go
1
star
65

lexec-go

exec.Command, but with logging
Go
1
star
66

pom

Maven POM parser in Go
Go
1
star