Skip to content

Commit a4cf6f1

Browse files
committed
README introduce v2
1 parent 8609301 commit a4cf6f1

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

README.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,29 @@ but unlike the last one, implementation is mutex free, following Go's idiom:
1616
* __Dynamic Sorting__: Sort bars as you wish
1717
* __Dynamic Resize__: Resize bars on terminal width change
1818
* __Custom Decorator Functions__: Add custom functions around the bar along with helper functions
19+
* __Dynamic Decorator's Width Sync__: Sync width among decorator group (column)
1920
* __Predefined Decoratros__: Elapsed time, [Ewmaest](https://github.com/dgryski/trifles/tree/master/ewmaest) based ETA, Percentage, Bytes counter
2021

22+
## Installation
23+
24+
To get the package, execute:
25+
26+
```sh
27+
go get gopkg.in/vbauerster/mpb.v1
28+
```
29+
30+
```sh
31+
go get gopkg.in/vbauerster/mpb.v2
32+
```
33+
2134
## Usage
2235

2336
Following is the simplest use case:
2437

2538
```go
2639
// Star mpb's rendering goroutine.
27-
// If you don't plan to cancel, feed with nil
28-
// otherwise provide context.Context, see cancel example
29-
p := mpb.New(nil)
30-
// Set custom width for every bar, which mpb will contain
40+
p := mpb.New()
41+
// Set custom width for every bar, which mpb will render
3142
// The default one in 70
3243
p.SetWidth(80)
3344
// Set custom format for every bar, the default one is "[=>-]"
@@ -36,7 +47,7 @@ Following is the simplest use case:
3647
p.RefreshRate(120 * time.Millisecond)
3748

3849
// Add a bar. You're not limited to just one bar, add many if you need.
39-
bar := p.AddBar(100).PrependName("Single Bar:", 0).AppendPercentage()
50+
bar := p.AddBar(100).PrependName("Single Bar:", 0, 0).AppendPercentage(5, 0)
4051

4152
for i := 0; i < 100; i++ {
4253
bar.Incr(1) // increment progress bar
@@ -59,11 +70,13 @@ own goroutine, therefore adding multiple bars is easy and safe:
5970

6071
```go
6172
var wg sync.WaitGroup
62-
p := mpb.New(nil)
73+
p := mpb.New()
74+
wg.Add(3) // add wg delta
6375
for i := 0; i < 3; i++ {
64-
wg.Add(1) // add wg delta
6576
name := fmt.Sprintf("Bar#%d:", i)
66-
bar := p.AddBar(100).PrependName(name, len(name)).AppendPercentage()
77+
bar := p.AddBar(100).
78+
PrependName(name, len(name), 0).
79+
AppendPercentage(5, 0)
6780
go func() {
6881
defer wg.Done()
6982
// you can p.AddBar() here, but ordering will be non deterministic
@@ -77,8 +90,6 @@ own goroutine, therefore adding multiple bars is easy and safe:
7790
}
7891
wg.Wait() // Wait for goroutines to finish
7992
p.Stop() // Stop mpb's rendering goroutine
80-
// p.AddBar(1) // panic: you cannot reuse p, create new one!
81-
fmt.Println("finish")
8293
```
8394

8495
![simple.gif](example/gifs/simple.gif)
@@ -119,12 +130,6 @@ The source code: [example/io/multiple/main.go](example/io/multiple/main.go)
119130

120131
[Here](https://github.com/vbauerster/getparty/blob/master/cmd/getparty/decorator.go) is example from [getparty](https://github.com/vbauerster/getparty) src code.
121132

122-
## Installation
123-
124-
```sh
125-
$ go get -u github.com/vbauerster/mpb
126-
```
127-
128133
## License
129134

130135
[MIT](https://github.com/vbauerster/mpb/blob/master/LICENSE)

0 commit comments

Comments
 (0)