-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
增加显示下载进度条的选项 #32
增加显示下载进度条的选项 #32
Conversation
Codecov Report
@@ Coverage Diff @@
## master #32 +/- ##
==========================================
- Coverage 39.58% 36.80% -2.78%
==========================================
Files 8 8
Lines 384 413 +29
==========================================
Hits 152 152
- Misses 218 247 +29
Partials 14 14
Continue to review full report at Codecov.
|
@@ -86,9 +86,15 @@ func install(ctx *cli.Context) (err error) { | |||
|
|||
if _, err = os.Stat(filename); os.IsNotExist(err) { | |||
// 本地不存在安装包,从远程下载并检查校验和。 | |||
if _, err = pkg.Download(filename); err != nil { | |||
var fn = pkg.Download | |||
if ctx.Bool("progress") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 命名果然是困扰程序员的一大难题,如非得有一个命令行的选项,那我可能选择
-vv
、-vvv
、--debug
之类的常见选项名。 - 之前在issue 25有过初步的设想,可能更加偏向于没有选项开关。
@@ -102,6 +105,39 @@ func (pkg *Package) Download(dst string) (size int64, err error) { | |||
return size, nil | |||
} | |||
|
|||
// DownloadWithProgress downloading file form specified url with verbosely progress bar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 显示下载进度还是挺有必要的,毕竟下载个安装包也得有几十秒吧。
@@ -27,6 +30,26 @@ func NewURLUnreachableError(url string, err error) error { | |||
} | |||
} | |||
|
|||
func RankedURL() string { | |||
if tmp := strings.TrimSpace(os.Getenv("G_MIRROR")); len(tmp) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 代码中内置一个镜像URL也并不太合适。通过环境变量读取一个自定义的镜像地址,已经足够应对中国大陆的网络需求,不想复杂化。
No description provided.