@cryptotaxi247 / kubo / commits / afb2afc7b

Move pb to gx

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed May 24, 2016 at 19:54 UTC afb2afc7bc829c136cc1e4012134ec4f3732b130
28 files changed +8 -1107
Godeps/_workspace/src/github.com/cheggaaa/pb/LICENSE deleted
-12
@@ -1,12 +0,0 @@
1 -Copyright (c) 2012, Sergey Cherepanov
2 -All rights reserved.
3 -
4 -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 -
6 -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 -
8 -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 -
10 -* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11 -
12 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
Godeps/_workspace/src/github.com/cheggaaa/pb/README.md deleted
-98
@@ -1,98 +0,0 @@
1 -## Terminal progress bar for Go
2 -
3 -Simple progress bar for console programms.
4 -
5 -
6 -### Installation
7 -```
8 -go get github.com/cheggaaa/pb
9 -```
10 -
11 -### Usage
12 -```Go
13 -package main
14 -
15 -import (
16 - "github.com/cheggaaa/pb"
17 - "time"
18 -)
19 -
20 -func main() {
21 - count := 100000
22 - bar := pb.StartNew(count)
23 - for i := 0; i < count; i++ {
24 - bar.Increment()
25 - time.Sleep(time.Millisecond)
26 - }
27 - bar.FinishPrint("The End!")
28 -}
29 -```
30 -Result will be like this:
31 -```
32 -> go run test.go
33 -37158 / 100000 [================>_______________________________] 37.16% 1m11s
34 -```
35 -
36 -
37 -More functions?
38 -```Go
39 -// create bar
40 -bar := pb.New(count)
41 -
42 -// refresh info every second (default 200ms)
43 -bar.SetRefreshRate(time.Second)
44 -
45 -// show percents (by default already true)
46 -bar.ShowPercent = true
47 -
48 -// show bar (by default already true)
49 -bar.ShowBar = true
50 -
51 -// no need counters
52 -bar.ShowCounters = false
53 -
54 -// show "time left"
55 -bar.ShowTimeLeft = true
56 -
57 -// show average speed
58 -bar.ShowSpeed = true
59 -
60 -// sets the width of the progress bar
61 -bar.SetWidth(80)
62 -
63 -// sets the width of the progress bar, but if terminal size smaller will be ignored
64 -bar.SetMaxWidth(80)
65 -
66 -// convert output to readable format (like KB, MB)
67 -bar.SetUnits(pb.U_BYTES)
68 -
69 -// and start
70 -bar.Start()
71 -```
72 -
73 -Want handle progress of io operations?
74 -```Go
75 -// create and start bar
76 -bar := pb.New(myDataLen).SetUnits(pb.U_BYTES)
77 -bar.Start()
78 -
79 -// my io.Reader
80 -r := myReader
81 -
82 -// my io.Writer
83 -w := myWriter
84 -
85 -// create multi writer
86 -writer := io.MultiWriter(w, bar)
87 -
88 -// and copy
89 -io.Copy(writer, r)
90 -
91 -// show example/copy/copy.go for advanced example
92 -
93 -```
94 -
95 -Not like the looks?
96 -```Go
97 -bar.Format("<.- >")
98 -```
Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go deleted
-81
@@ -1,81 +0,0 @@
1 -package main
2 -
3 -import (
4 - "fmt"
5 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
6 - "io"
7 - "net/http"
8 - "os"
9 - "strconv"
10 - "strings"
11 - "time"
12 -)
13 -
14 -func main() {
15 - // check args
16 - if len(os.Args) < 3 {
17 - printUsage()
18 - return
19 - }
20 - sourceName, destName := os.Args[1], os.Args[2]
21 -
22 - // check source
23 - var source io.Reader
24 - var sourceSize int64
25 - if strings.HasPrefix(sourceName, "http://") {
26 - // open as url
27 - resp, err := http.Get(sourceName)
28 - if err != nil {
29 - fmt.Printf("Can't get %s: %v\n", sourceName, err)
30 - return
31 - }
32 - defer resp.Body.Close()
33 - if resp.StatusCode != http.StatusOK {
34 - fmt.Printf("Server return non-200 status: %v\n", resp.Status)
35 - return
36 - }
37 - i, _ := strconv.Atoi(resp.Header.Get("Content-Length"))
38 - sourceSize = int64(i)
39 - source = resp.Body
40 - } else {
41 - // open as file
42 - s, err := os.Open(sourceName)
43 - if err != nil {
44 - fmt.Printf("Can't open %s: %v\n", sourceName, err)
45 - return
46 - }
47 - defer s.Close()
48 - // get source size
49 - sourceStat, err := s.Stat()
50 - if err != nil {
51 - fmt.Printf("Can't stat %s: %v\n", sourceName, err)
52 - return
53 - }
54 - sourceSize = sourceStat.Size()
55 - source = s
56 - }
57 -
58 - // create dest
59 - dest, err := os.Create(destName)
60 - if err != nil {
61 - fmt.Printf("Can't create %s: %v\n", destName, err)
62 - return
63 - }
64 - defer dest.Close()
65 -
66 - // create bar
67 - bar := pb.New(int(sourceSize)).SetUnits(pb.U_BYTES).SetRefreshRate(time.Millisecond * 10)
68 - bar.ShowSpeed = true
69 - bar.Start()
70 -
71 - // create multi writer
72 - writer := io.MultiWriter(dest, bar)
73 -
74 - // and copy
75 - io.Copy(writer, source)
76 - bar.Finish()
77 -}
78 -
79 -func printUsage() {
80 - fmt.Println("copy [source file or url] [dest file]")
81 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/example/pb.go deleted
-30
@@ -1,30 +0,0 @@
1 -package main
2 -
3 -import (
4 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
5 - "time"
6 -)
7 -
8 -func main() {
9 - count := 5000
10 - bar := pb.New(count)
11 -
12 - // show percents (by default already true)
13 - bar.ShowPercent = true
14 -
15 - // show bar (by default already true)
16 - bar.ShowPercent = true
17 -
18 - // no need counters
19 - bar.ShowCounters = true
20 -
21 - bar.ShowTimeLeft = true
22 -
23 - // and start
24 - bar.Start()
25 - for i := 0; i < count; i++ {
26 - bar.Increment()
27 - time.Sleep(time.Millisecond)
28 - }
29 - bar.FinishPrint("The End!")
30 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/format.go deleted
-45
@@ -1,45 +0,0 @@
1 -package pb
2 -
3 -import (
4 - "fmt"
5 - "strconv"
6 - "strings"
7 -)
8 -
9 -type Units int
10 -
11 -const (
12 - // By default, without type handle
13 - U_NO Units = iota
14 - // Handle as b, Kb, Mb, etc
15 - U_BYTES
16 -)
17 -
18 -// Format integer
19 -func Format(i int64, units Units) string {
20 - switch units {
21 - case U_BYTES:
22 - return FormatBytes(i)
23 - default:
24 - // by default just convert to string
25 - return strconv.FormatInt(i, 10)
26 - }
27 -}
28 -
29 -// Convert bytes to human readable string. Like a 2 MB, 64.2 KB, 52 B
30 -func FormatBytes(i int64) (result string) {
31 - switch {
32 - case i > (1024 * 1024 * 1024 * 1024):
33 - result = fmt.Sprintf("%#.02f TB", float64(i)/1024/1024/1024/1024)
34 - case i > (1024 * 1024 * 1024):
35 - result = fmt.Sprintf("%#.02f GB", float64(i)/1024/1024/1024)
36 - case i > (1024 * 1024):
37 - result = fmt.Sprintf("%#.02f MB", float64(i)/1024/1024)
38 - case i > 1024:
39 - result = fmt.Sprintf("%#.02f KB", float64(i)/1024)
40 - default:
41 - result = fmt.Sprintf("%d B", i)
42 - }
43 - result = strings.Trim(result, " ")
44 - return
45 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/format_test.go deleted
-37
@@ -1,37 +0,0 @@
1 -package pb
2 -
3 -import (
4 - "fmt"
5 - "strconv"
6 - "testing"
7 -)
8 -
9 -func Test_DefaultsToInteger(t *testing.T) {
10 - value := int64(1000)
11 - expected := strconv.Itoa(int(value))
12 - actual := Format(value, -1)
13 -
14 - if actual != expected {
15 - t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
16 - }
17 -}
18 -
19 -func Test_CanFormatAsInteger(t *testing.T) {
20 - value := int64(1000)
21 - expected := strconv.Itoa(int(value))
22 - actual := Format(value, U_NO)
23 -
24 - if actual != expected {
25 - t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
26 - }
27 -}
28 -
29 -func Test_CanFormatAsBytes(t *testing.T) {
30 - value := int64(1000)
31 - expected := "1000 B"
32 - actual := Format(value, U_BYTES)
33 -
34 - if actual != expected {
35 - t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
36 - }
37 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/pb.go deleted
-352
@@ -1,352 +0,0 @@
1 -package pb
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "math"
7 - "strings"
8 - "sync"
9 - "sync/atomic"
10 - "time"
11 -)
12 -
13 -const (
14 - // Default refresh rate - 200ms
15 - DEFAULT_REFRESH_RATE = time.Millisecond * 200
16 - FORMAT = "[=>-]"
17 -)
18 -
19 -// DEPRECATED
20 -// variables for backward compatibility, from now do not work
21 -// use pb.Format and pb.SetRefreshRate
22 -var (
23 - DefaultRefreshRate = DEFAULT_REFRESH_RATE
24 - BarStart, BarEnd, Empty, Current, CurrentN string
25 -)
26 -
27 -// Create new progress bar object
28 -func New(total int) *ProgressBar {
29 - return New64(int64(total))
30 -}
31 -
32 -// Create new progress bar object uding int64 as total
33 -func New64(total int64) *ProgressBar {
34 - pb := &ProgressBar{
35 - Total: total,
36 - RefreshRate: DEFAULT_REFRESH_RATE,
37 - ShowPercent: true,
38 - ShowCounters: true,
39 - ShowBar: true,
40 - ShowTimeLeft: true,
41 - ShowFinalTime: true,
42 - Units: U_NO,
43 - ManualUpdate: false,
44 - isFinish: make(chan struct{}),
45 - currentValue: -1,
46 - }
47 - return pb.Format(FORMAT)
48 -}
49 -
50 -// Create new object and start
51 -func StartNew(total int) *ProgressBar {
52 - return New(total).Start()
53 -}
54 -
55 -// Callback for custom output
56 -// For example:
57 -// bar.Callback = func(s string) {
58 -// mySuperPrint(s)
59 -// }
60 -//
61 -type Callback func(out string)
62 -
63 -type ProgressBar struct {
64 - current int64 // current must be first member of struct (https://code.google.com/p/go/issues/detail?id=5278)
65 -
66 - Total int64
67 - RefreshRate time.Duration
68 - ShowPercent, ShowCounters bool
69 - ShowSpeed, ShowTimeLeft, ShowBar bool
70 - ShowFinalTime bool
71 - Output io.Writer
72 - Callback Callback
73 - NotPrint bool
74 - Units Units
75 - Width int
76 - ForceWidth bool
77 - ManualUpdate bool
78 -
79 - finishOnce sync.Once //Guards isFinish
80 - isFinish chan struct{}
81 -
82 - startTime time.Time
83 - startValue int64
84 - currentValue int64
85 -
86 - prefix, postfix string
87 -
88 - BarStart string
89 - BarEnd string
90 - Empty string
91 - Current string
92 - CurrentN string
93 -}
94 -
95 -// Start print
96 -func (pb *ProgressBar) Start() *ProgressBar {
97 - pb.startTime = time.Now()
98 - pb.startValue = pb.current
99 - if pb.Total == 0 {
100 - pb.ShowBar = false
101 - pb.ShowTimeLeft = false
102 - pb.ShowPercent = false
103 - }
104 - if !pb.ManualUpdate {
105 - go pb.writer()
106 - }
107 - return pb
108 -}
109 -
110 -// Increment current value
111 -func (pb *ProgressBar) Increment() int {
112 - return pb.Add(1)
113 -}
114 -
115 -// Set current value
116 -func (pb *ProgressBar) Set(current int) *ProgressBar {
117 - return pb.Set64(int64(current))
118 -}
119 -
120 -// Set64 sets the current value as int64
121 -func (pb *ProgressBar) Set64(current int64) *ProgressBar {
122 - atomic.StoreInt64(&pb.current, current)
123 - return pb
124 -}
125 -
126 -// Add to current value
127 -func (pb *ProgressBar) Add(add int) int {
128 - return int(pb.Add64(int64(add)))
129 -}
130 -
131 -func (pb *ProgressBar) Add64(add int64) int64 {
132 - return atomic.AddInt64(&pb.current, add)
133 -}
134 -
135 -// Set prefix string
136 -func (pb *ProgressBar) Prefix(prefix string) *ProgressBar {
137 - pb.prefix = prefix
138 - return pb
139 -}
140 -
141 -// Set postfix string
142 -func (pb *ProgressBar) Postfix(postfix string) *ProgressBar {
143 - pb.postfix = postfix
144 - return pb
145 -}
146 -
147 -// Set custom format for bar
148 -// EXAMPLE: bar.Format("[=>_]")
149 -func (pb *ProgressBar) Format(format string) *ProgressBar {
150 - formatEntries := strings.Split(format, "")
151 - if len(formatEntries) == 5 {
152 - pb.BarStart = formatEntries[0]
153 - pb.BarEnd = formatEntries[4]
154 - pb.Empty = formatEntries[3]
155 - pb.Current = formatEntries[1]
156 - pb.CurrentN = formatEntries[2]
157 - }
158 - return pb
159 -}
160 -
161 -// Set bar refresh rate
162 -func (pb *ProgressBar) SetRefreshRate(rate time.Duration) *ProgressBar {
163 - pb.RefreshRate = rate
164 - return pb
165 -}
166 -
167 -// Set units
168 -// bar.SetUnits(U_NO) - by default
169 -// bar.SetUnits(U_BYTES) - for Mb, Kb, etc
170 -func (pb *ProgressBar) SetUnits(units Units) *ProgressBar {
171 - pb.Units = units
172 - return pb
173 -}
174 -
175 -// Set max width, if width is bigger than terminal width, will be ignored
176 -func (pb *ProgressBar) SetMaxWidth(width int) *ProgressBar {
177 - pb.Width = width
178 - pb.ForceWidth = false
179 - return pb
180 -}
181 -
182 -// Set bar width
183 -func (pb *ProgressBar) SetWidth(width int) *ProgressBar {
184 - pb.Width = width
185 - pb.ForceWidth = true
186 - return pb
187 -}
188 -
189 -// End print
190 -func (pb *ProgressBar) Finish() {
191 - //Protect multiple calls
192 - pb.finishOnce.Do(func() {
193 - close(pb.isFinish)
194 - pb.write(atomic.LoadInt64(&pb.current))
195 - if !pb.NotPrint {
196 - fmt.Println()
197 - }
198 - })
199 -}
200 -
201 -// End print and write string 'str'
202 -func (pb *ProgressBar) FinishPrint(str string) {
203 - pb.Finish()
204 - fmt.Println(str)
205 -}
206 -
207 -// implement io.Writer
208 -func (pb *ProgressBar) Write(p []byte) (n int, err error) {
209 - n = len(p)
210 - pb.Add(n)
211 - return
212 -}
213 -
214 -// implement io.Reader
215 -func (pb *ProgressBar) Read(p []byte) (n int, err error) {
216 - n = len(p)
217 - pb.Add(n)
218 - return
219 -}
220 -
221 -// Create new proxy reader over bar
222 -func (pb *ProgressBar) NewProxyReader(r io.Reader) *Reader {
223 - return &Reader{r, pb}
224 -}
225 -
226 -func (pb *ProgressBar) write(current int64) {
227 - width := pb.getWidth()
228 -
229 - var percentBox, countersBox, timeLeftBox, speedBox, barBox, end, out string
230 -
231 - // percents
232 - if pb.ShowPercent {
233 - percent := float64(current) / (float64(pb.Total) / float64(100))
234 - percentBox = fmt.Sprintf(" %#.02f %% ", percent)
235 - }
236 -
237 - // counters
238 - if pb.ShowCounters {
239 - if pb.Total > 0 {
240 - countersBox = fmt.Sprintf("%s / %s ", Format(current, pb.Units), Format(pb.Total, pb.Units))
241 - } else {
242 - countersBox = Format(current, pb.Units) + " "
243 - }
244 - }
245 -
246 - // time left
247 - fromStart := time.Now().Sub(pb.startTime)
248 - currentFromStart := current - pb.startValue
249 - select {
250 - case <-pb.isFinish:
251 - if pb.ShowFinalTime {
252 - left := (fromStart / time.Second) * time.Second
253 - timeLeftBox = left.String()
254 - }
255 - default:
256 - if pb.ShowTimeLeft && currentFromStart > 0 {
257 - perEntry := fromStart / time.Duration(currentFromStart)
258 - left := time.Duration(pb.Total-currentFromStart) * perEntry
259 - left = (left / time.Second) * time.Second
260 - timeLeftBox = left.String()
261 - }
262 - }
263 -
264 - // speed
265 - if pb.ShowSpeed && currentFromStart > 0 {
266 - fromStart := time.Now().Sub(pb.startTime)
267 - speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second))
268 - speedBox = Format(int64(speed), pb.Units) + "/s "
269 - }
270 -
271 - // bar
272 - if pb.ShowBar {
273 - size := width - len(countersBox+pb.BarStart+pb.BarEnd+percentBox+timeLeftBox+speedBox+pb.prefix+pb.postfix)
274 - if size > 0 && pb.Total > 0 {
275 - curCount := int(math.Ceil((float64(current) / float64(pb.Total)) * float64(size)))
276 - emptCount := size - curCount
277 - barBox = pb.BarStart
278 - if emptCount < 0 {
279 - emptCount = 0
280 - }
281 - if curCount > size {
282 - curCount = size
283 - }
284 - if emptCount <= 0 {
285 - barBox += strings.Repeat(pb.Current, curCount)
286 - } else if curCount > 0 {
287 - barBox += strings.Repeat(pb.Current, curCount-1) + pb.CurrentN
288 - }
289 -
290 - barBox += strings.Repeat(pb.Empty, emptCount) + pb.BarEnd
291 - }
292 - }
293 -
294 - // check len
295 - out = pb.prefix + countersBox + barBox + percentBox + speedBox + timeLeftBox + pb.postfix
296 - if len(out) < width {
297 - end = strings.Repeat(" ", width-len(out))
298 - }
299 -
300 - // and print!
301 - switch {
302 - case pb.Output != nil:
303 - fmt.Fprint(pb.Output, "\r"+out+end)
304 - case pb.Callback != nil:
305 - pb.Callback(out + end)
306 - case !pb.NotPrint:
307 - fmt.Print("\r" + out + end)
308 - }
309 -}
310 -
311 -func (pb *ProgressBar) getWidth() int {
312 - if pb.ForceWidth {
313 - return pb.Width
314 - }
315 -
316 - width := pb.Width
317 - termWidth, _ := terminalWidth()
318 - if width == 0 || termWidth <= width {
319 - width = termWidth
320 - }
321 -
322 - return width
323 -}
324 -
325 -// Write the current state of the progressbar
326 -func (pb *ProgressBar) Update() {
327 - c := atomic.LoadInt64(&pb.current)
328 - if c != pb.currentValue {
329 - pb.write(c)
330 - pb.currentValue = c
331 - }
332 -}
333 -
334 -// Internal loop for writing progressbar
335 -func (pb *ProgressBar) writer() {
336 - pb.Update()
337 - for {
338 - select {
339 - case <-pb.isFinish:
340 - return
341 - case <-time.After(pb.RefreshRate):
342 - pb.Update()
343 - }
344 - }
345 -}
346 -
347 -type window struct {
348 - Row uint16
349 - Col uint16
350 - Xpixel uint16
351 - Ypixel uint16
352 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/pb_nix.go deleted
-7
@@ -1,7 +0,0 @@
1 -// +build linux darwin freebsd netbsd openbsd
2 -
3 -package pb
4 -
5 -import "syscall"
6 -
7 -const sys_ioctl = syscall.SYS_IOCTL
Godeps/_workspace/src/github.com/cheggaaa/pb/pb_solaris.go deleted
-5
@@ -1,5 +0,0 @@
1 -// +build solaris
2 -
3 -package pb
4 -
5 -const sys_ioctl = 54
Godeps/_workspace/src/github.com/cheggaaa/pb/pb_test.go deleted
-37
@@ -1,37 +0,0 @@
1 -package pb
2 -
3 -import (
4 - "testing"
5 -)
6 -
7 -func Test_IncrementAddsOne(t *testing.T) {
8 - count := 5000
9 - bar := New(count)
10 - expected := 1
11 - actual := bar.Increment()
12 -
13 - if actual != expected {
14 - t.Errorf("Expected {%d} was {%d}", expected, actual)
15 - }
16 -}
17 -
18 -func Test_Width(t *testing.T) {
19 - count := 5000
20 - bar := New(count)
21 - width := 100
22 - bar.SetWidth(100).Callback = func(out string) {
23 - if len(out) != width {
24 - t.Errorf("Bar width expected {%d} was {%d}", len(out), width)
25 - }
26 - }
27 - bar.Start()
28 - bar.Increment()
29 - bar.Finish()
30 -}
31 -
32 -func Test_MultipleFinish(t *testing.T) {
33 - bar := New(5000)
34 - bar.Add(2000)
35 - bar.Finish()
36 - bar.Finish()
37 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/pb_win.go deleted
-16
@@ -1,16 +0,0 @@
1 -// +build windows
2 -
3 -package pb
4 -
5 -import (
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/olekukonko/ts"
7 -)
8 -
9 -func bold(str string) string {
10 - return str
11 -}
12 -
13 -func terminalWidth() (int, error) {
14 - size, err := ts.GetSize()
15 - return size.Col(), err
16 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/pb_x.go deleted
-46
@@ -1,46 +0,0 @@
1 -// +build linux darwin freebsd netbsd openbsd solaris
2 -
3 -package pb
4 -
5 -import (
6 - "os"
7 - "runtime"
8 - "syscall"
9 - "unsafe"
10 -)
11 -
12 -const (
13 - TIOCGWINSZ = 0x5413
14 - TIOCGWINSZ_OSX = 1074295912
15 -)
16 -
17 -var tty *os.File
18 -
19 -func init() {
20 - var err error
21 - tty, err = os.Open("/dev/tty")
22 - if err != nil {
23 - tty = os.Stdin
24 - }
25 -}
26 -
27 -func bold(str string) string {
28 - return "\033[1m" + str + "\033[0m"
29 -}
30 -
31 -func terminalWidth() (int, error) {
32 - w := new(window)
33 - tio := syscall.TIOCGWINSZ
34 - if runtime.GOOS == "darwin" {
35 - tio = TIOCGWINSZ_OSX
36 - }
37 - res, _, err := syscall.Syscall(sys_ioctl,
38 - tty.Fd(),
39 - uintptr(tio),
40 - uintptr(unsafe.Pointer(w)),
41 - )
42 - if int(res) == -1 {
43 - return 0, err
44 - }
45 - return int(w.Col), nil
46 -}
Godeps/_workspace/src/github.com/cheggaaa/pb/reader.go deleted
-17
@@ -1,17 +0,0 @@
1 -package pb
2 -
3 -import (
4 - "io"
5 -)
6 -
7 -// It's proxy reader, implement io.Reader
8 -type Reader struct {
9 - io.Reader
10 - bar *ProgressBar
11 -}
12 -
13 -func (r *Reader) Read(p []byte) (n int, err error) {
14 - n, err = r.Reader.Read(p)
15 - r.bar.Add(n)
16 - return
17 -}
Godeps/_workspace/src/github.com/olekukonko/ts/.travis.yml deleted
-6
@@ -1,6 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.1
5 - - 1.2
6 - - tip
\ No newline at end of file
Godeps/_workspace/src/github.com/olekukonko/ts/LICENCE deleted
-19
@@ -1,19 +0,0 @@
1 -Copyright (C) 2014 by Oleku Konko
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy
4 -of this software and associated documentation files (the "Software"), to deal
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in
11 -all copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -THE SOFTWARE.
\ No newline at end of file
Godeps/_workspace/src/github.com/olekukonko/ts/README.md deleted
-28
@@ -1,28 +0,0 @@
1 -ts (Terminal Size)
2 -==
3 -
4 -[![Build Status](https://travis-ci.org/olekukonko/ts.png?branch=master)](https://travis-ci.org/olekukonko/ts) [![Total views](https://sourcegraph.com/api/repos/github.com/olekukonko/ts/counters/views.png)](https://sourcegraph.com/github.com/olekukonko/ts)
5 -
6 -Simple go Application to get Terminal Size. So Many Implementations do not support windows but `ts` has full windows support.
7 -Run `go get github.com/olekukonko/ts` to download and install
8 -
9 -#### Example
10 -
11 -```go
12 -package main
13 -
14 -import (
15 - "fmt"
16 - "github.com/olekukonko/ts"
17 -)
18 -
19 -func main() {
20 - size, _ := ts.GetSize()
21 - fmt.Println(size.Col()) // Get Width
22 - fmt.Println(size.Row()) // Get Height
23 - fmt.Println(size.PosX()) // Get X position
24 - fmt.Println(size.PosY()) // Get Y position
25 -}
26 -```
27 -
28 -[See Documentation](http://godoc.org/github.com/olekukonko/ts)
Godeps/_workspace/src/github.com/olekukonko/ts/doc.go deleted
-36
@@ -1,36 +0,0 @@
1 -// Copyright 2014 Oleku Konko All rights reserved.
2 -// Use of this source code is governed by a MIT
3 -// license that can be found in the LICENSE file.
4 -
5 -// This module is a Terminal API for the Go Programming Language.
6 -// The protocols were written in pure Go and works on windows and unix systems
7 -
8 -/**
9 -
10 -Simple go Application to get Terminal Size. So Many Implementations do not support windows but `ts` has full windows support.
11 -Run `go get github.com/olekukonko/ts` to download and install
12 -
13 -Installation
14 -
15 -Minimum requirements are Go 1.1+ with fill Windows support
16 -
17 -Example
18 -
19 - package main
20 -
21 - import (
22 - "fmt"
23 - "github.com/olekukonko/ts"
24 - )
25 -
26 - func main() {
27 - size, _ := ts.GetSize()
28 - fmt.Println(size.Col()) // Get Width
29 - fmt.Println(size.Row()) // Get Height
30 - fmt.Println(size.PosX()) // Get X position
31 - fmt.Println(size.PosY()) // Get Y position
32 - }
33 -
34 -**/
35 -
36 -package ts
Godeps/_workspace/src/github.com/olekukonko/ts/ts.go deleted
-36
@@ -1,36 +0,0 @@
1 -// Copyright 2014 Oleku Konko All rights reserved.
2 -// Use of this source code is governed by a MIT
3 -// license that can be found in the LICENSE file.
4 -
5 -// This module is a Terminal API for the Go Programming Language.
6 -// The protocols were written in pure Go and works on windows and unix systems
7 -
8 -package ts
9 -
10 -// Return System Size
11 -type Size struct {
12 - row uint16
13 - col uint16
14 - posX uint16
15 - posY uint16
16 -}
17 -
18 -// Get Terminal Width
19 -func (w Size) Col() int {
20 - return int(w.col)
21 -}
22 -
23 -// Get Terminal Height
24 -func (w Size) Row() int {
25 - return int(w.row)
26 -}
27 -
28 -// Get Position X
29 -func (w Size) PosX() int {
30 - return int(w.posX)
31 -}
32 -
33 -// Get Position Y
34 -func (w Size) PosY() int {
35 - return int(w.posY)
36 -}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_darwin.go deleted
-14
@@ -1,14 +0,0 @@
1 -// +build darwin
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -const (
13 - TIOCGWINSZ = 0x40087468
14 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_linux.go deleted
-13
@@ -1,13 +0,0 @@
1 -// +build linux
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -package ts
10 -
11 -const (
12 - TIOCGWINSZ = 0x5413
13 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_other.go deleted
-14
@@ -1,14 +0,0 @@
1 -// +build !windows,!darwin,!freebsd,!netbsd,!openbsd,!linux
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -const (
13 - TIOCGWINSZ = 0
14 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_test.go deleted
-32
@@ -1,32 +0,0 @@
1 -// Copyright 2014 Oleku Konko All rights reserved.
2 -// Use of this source code is governed by a MIT
3 -// license that can be found in the LICENSE file.
4 -
5 -// This module is a Terminal API for the Go Programming Language.
6 -// The protocols were written in pure Go and works on windows and unix systems
7 -
8 -package ts
9 -
10 -import (
11 - "fmt"
12 - "testing"
13 -)
14 -
15 -func ExampleGetSize() {
16 - size, _ := GetSize()
17 - fmt.Println(size.Col()) // Get Width
18 - fmt.Println(size.Row()) // Get Height
19 - fmt.Println(size.PosX()) // Get X position
20 - fmt.Println(size.PosY()) // Get Y position
21 -}
22 -
23 -func TestSize(t *testing.T) {
24 - size, err := GetSize()
25 -
26 - if err != nil {
27 - t.Fatal(err)
28 - }
29 - if size.Col() == 0 || size.Row() == 0 {
30 - t.Fatalf("Screen Size Failed")
31 - }
32 -}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_unix.go deleted
-14
@@ -1,14 +0,0 @@
1 -// +build freebsd netbsd openbsd
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -const (
13 - TIOCGWINSZ = 0x40087468
14 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_windows.go deleted
-64
@@ -1,64 +0,0 @@
1 -// +build windows
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -import (
13 - "syscall"
14 - "unsafe"
15 -)
16 -
17 -var (
18 - kernel32 = syscall.NewLazyDLL("kernel32.dll")
19 -
20 - // Retrieves information about the specified console screen buffer.
21 - // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx
22 - screenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
23 -)
24 -
25 -// Contains information about a console screen buffer.
26 -// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
27 -type CONSOLE_SCREEN_BUFFER_INFO struct {
28 - DwSize COORD
29 - DwCursorPosition COORD
30 - WAttributes uint16
31 - SrWindow SMALL_RECT
32 - DwMaximumWindowSize COORD
33 -}
34 -
35 -// Defines the coordinates of a character cell in a console screen buffer.
36 -// The origin of the coordinate system (0,0) is at the top, left cell of the buffer.
37 -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119(v=vs.85).aspx
38 -type COORD struct {
39 - X, Y uint16
40 -}
41 -
42 -// Defines the coordinates of the upper left and lower right corners of a rectangle.
43 -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311(v=vs.85).aspx
44 -type SMALL_RECT struct {
45 - Left, Top, Right, Bottom uint16
46 -}
47 -
48 -func GetSize() (ws Size, err error) {
49 - var info CONSOLE_SCREEN_BUFFER_INFO
50 - rc, _, err := screenBufferInfo.Call(
51 - uintptr(syscall.Stdout),
52 - uintptr(unsafe.Pointer(&info)))
53 -
54 - if rc == 0 {
55 - return ws, err
56 - }
57 -
58 - ws = Size{info.SrWindow.Bottom,
59 - info.SrWindow.Right,
60 - info.DwCursorPosition.X,
61 - info.DwCursorPosition.Y}
62 -
63 - return ws, nil
64 -}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_x.go deleted
-46
@@ -1,46 +0,0 @@
1 -// +build !windows
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -import (
13 - "syscall"
14 - "unsafe"
15 -)
16 -
17 -// Get Windows Size
18 -func GetSize() (ws Size, err error) {
19 - _, _, ec := syscall.Syscall(syscall.SYS_IOCTL,
20 - uintptr(syscall.Stdout),
21 - uintptr(TIOCGWINSZ),
22 - uintptr(unsafe.Pointer(&ws)))
23 -
24 - err = getError(ec)
25 -
26 - if TIOCGWINSZ == 0 && err != nil {
27 - ws = Size{80, 25, 0, 0}
28 - }
29 - return ws, err
30 -}
31 -
32 -func getError(ec interface{}) (err error) {
33 - switch v := ec.(type) {
34 -
35 - case syscall.Errno: // Some implementation return syscall.Errno number
36 - if v != 0 {
37 - err = syscall.Errno(v)
38 - }
39 -
40 - case error: // Some implementation return error
41 - err = ec.(error)
42 - default:
43 - err = nil
44 - }
45 - return
46 -}
core/commands/add.go
+1 -1
@@ -4,8 +4,8 @@ import (
4 "fmt"
5 "io"
6
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
7 "github.com/ipfs/go-ipfs/core/coreunix"
8 + "gx/ipfs/QmeWjRodbcZFKe5tMN7poEx3izym6osrLSnTLf9UjJZBbs/pb"
9
10 cmds "github.com/ipfs/go-ipfs/commands"
11 files "github.com/ipfs/go-ipfs/commands/files"
core/commands/get.go
+1 -1
@@ -9,7 +9,7 @@ import (
9 gopath "path"
10 "strings"
11
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cheggaaa/pb"
12 + "gx/ipfs/QmeWjRodbcZFKe5tMN7poEx3izym6osrLSnTLf9UjJZBbs/pb"
13
14 cmds "github.com/ipfs/go-ipfs/commands"
15 core "github.com/ipfs/go-ipfs/core"
package.json
+6
@@ -93,6 +93,12 @@
93 "hash": "QmYnf27kzqR2cxt6LFZdrAFJuQd6785fTkBvMuEj9EeRxM",
94 "name": "proquint",
95 "version": "0.0.0"
96 + },
97 + {
98 + "author": "cheggaaa",
99 + "hash": "QmeWjRodbcZFKe5tMN7poEx3izym6osrLSnTLf9UjJZBbs",
100 + "name": "pb",
101 + "version": "1.0.3"
102 }
103 ],
104 "gxVersion": "0.4.0",