Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit f514461

Browse files
committed
code update
1 parent 2faf55c commit f514461

File tree

10 files changed

+82
-64
lines changed

10 files changed

+82
-64
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
13-
13+
build/
1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/

bali.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://toml.io/en/
2+
name = "bulk"
3+
version = "1.0.0"
4+
dirs = [
5+
"cmd/rind", # dirs
6+
]
7+
8+
[[files]]
9+
path = "LICENSE"
10+
destination = "share"
11+
newname = "copyright.txt"
12+
norename = true

base/unix.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// +build !windows
2+
3+
package base
4+
5+
func FixupTerminal() {
6+
//
7+
}

base/windows.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// +build windows
2+
3+
package base
4+
5+
import (
6+
"os"
7+
8+
"golang.org/x/sys/windows"
9+
)
10+
11+
// const
12+
const (
13+
EnableVirtualTerminalProcessingMode = 0x4
14+
)
15+
16+
func init() {
17+
FixupTerminal()
18+
}
19+
20+
// FixupTerminal becasue
21+
func FixupTerminal() {
22+
var mode uint32
23+
// becasue we print message to stderr
24+
fd := os.Stderr.Fd()
25+
if windows.GetConsoleMode(windows.Handle(fd), &mode) == nil {
26+
_ = windows.SetConsoleMode(windows.Handle(fd), mode|EnableVirtualTerminalProcessingMode)
27+
}
28+
}

cmd/rind/balisrc.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name = "rind"
2+
description = "rind - Interesting command line download tool"
3+
destination = "bin"
4+
version = "1.0.0"
5+
goflags = [
6+
"-ldflags",
7+
"-X 'main.VERSION=$BUILD_VERSION' -X 'main.BUILDTIME=$BUILD_TIME' -X 'main.BUILDBRANCH=$BUILD_BRANCH' -X 'main.BUILDCOMMIT=$BUILD_COMMIT' -X 'main.GOVERSION=$BUILD_GOVERSION'",
8+
]

cmd/rind/windows.go

-29
This file was deleted.

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ go 1.14
55
require (
66
github.com/andybalholm/brotli v1.0.0
77
github.com/dsnet/compress v0.0.1
8-
github.com/frankban/quicktest v1.10.0 // indirect
8+
github.com/frankban/quicktest v1.10.1 // indirect
99
github.com/google/go-cmp v0.5.1 // indirect
1010
github.com/klauspost/compress v1.10.11
11-
github.com/kr/pretty v0.2.1 // indirect
1211
github.com/kr/text v0.2.0 // indirect
1312
github.com/mattn/go-isatty v0.0.12
1413
github.com/mattn/go-runewidth v0.0.9
@@ -18,7 +17,8 @@ require (
1817
github.com/ulikunitz/xz v0.5.7
1918
github.com/zeebo/blake3 v0.0.4
2019
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
21-
golang.org/x/net v0.0.0-20200707034311-ab3426394381
22-
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed
20+
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc
21+
golang.org/x/sys v0.0.0-20200819091447-39769834ee22
2322
golang.org/x/text v0.3.3
23+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
2424
)

go.sum

+8-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5Jflh
99
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
1010
github.com/frankban/quicktest v1.4.0 h1:rCSCih1FnSWJEel/eub9wclBSqpF2F/PuvxUWGWnbO8=
1111
github.com/frankban/quicktest v1.4.0/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ=
12-
github.com/frankban/quicktest v1.10.0 h1:Gfh+GAJZOAoKZsIZeZbdn2JF10kN1XHNvjsvQK8gVkE=
13-
github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y=
12+
github.com/frankban/quicktest v1.10.1 h1:y7Vn4YH/rfUHOCwNhvkAcA0gMQvFdKzSE8Ri3qtcFlc=
13+
github.com/frankban/quicktest v1.10.1/go.mod h1:z7wHrVXJKCWP1Ev7B3iy2DivmuL5uGeeJDWYz/6LLhY=
1414
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
1515
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1616
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
@@ -20,15 +20,11 @@ github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
2020
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2121
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
2222
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
23-
github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd/0B3I=
24-
github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
2523
github.com/klauspost/compress v1.10.11 h1:K9z59aO18Aywg2b/WSgBaUX99mHy2BES18Cr5lBKZHk=
2624
github.com/klauspost/compress v1.10.11/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
2725
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
2826
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
2927
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
30-
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
31-
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
3228
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
3329
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
3430
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -71,25 +67,25 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
7167
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
7268
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
7369
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
74-
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
75-
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
70+
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4=
71+
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
7672
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7773
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7874
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7975
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8076
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8177
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8278
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
83-
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 h1:sIky/MyNRSHTrdxfsiUSS4WIAMvInbeXljJz+jDjeYE=
84-
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
85-
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed h1:WBkVNH1zd9jg/dK4HCM4lNANnmd12EHC9z+LmcCG4ns=
86-
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
79+
golang.org/x/sys v0.0.0-20200819091447-39769834ee22 h1:YUxhQGxYV280Da2a0XZiHblyJZN6NuXS1f4dahsm0SM=
80+
golang.org/x/sys v0.0.0-20200819091447-39769834ee22/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8781
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8882
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
8983
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
9084
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9185
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
9286
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
87+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
88+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
9389
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9490
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
9591
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=

netutils/executor.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,20 @@ func (e *Executor) WebGet(eu *EnhanceURL) (string, error) {
284284
if err != nil {
285285
return "", err
286286
}
287-
bar := progressbar.DefaultBytes(
288-
resp.ContentLength,
289-
fileNameOrDescription(filename),
290-
)
287+
var bar *progressbar.ProgressBar
288+
if runewidth.StringWidth(filename) > 20 {
289+
fmt.Fprintf(os.Stderr, "\x1b[33mdownload %s\x1b[0m\n", filename)
290+
bar = progressbar.DefaultBytes(
291+
resp.ContentLength,
292+
"downloading",
293+
)
294+
} else {
295+
bar = progressbar.DefaultBytes(
296+
resp.ContentLength,
297+
filename,
298+
)
299+
}
300+
291301
var w io.Writer
292302
if verifier != nil {
293303
w = io.MultiWriter(fd, bar, verifier.H)

progressbar/getwidth_windows.go

-14
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,3 @@ func getWidth() int {
4949
}
5050
return 80
5151
}
52-
53-
// const
54-
const (
55-
EnableVirtualTerminalProcessingMode = 0x4
56-
)
57-
58-
func init() {
59-
var mode uint32
60-
// becasue we print message to stderr
61-
fd := os.Stderr.Fd()
62-
if windows.GetConsoleMode(windows.Handle(fd), &mode) == nil {
63-
_ = windows.SetConsoleMode(windows.Handle(fd), mode|EnableVirtualTerminalProcessingMode)
64-
}
65-
}

0 commit comments

Comments
 (0)