Skip to content
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

Merged
merged 8 commits into from
Aug 2, 2020
Merged

Conversation

mingcheng
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2020

Codecov Report

Merging #32 into master will decrease coverage by 2.77%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
cli/install.go 0.00% <0.00%> (ø)
cli/ls_remote.go 0.00% <0.00%> (ø)
version/collector.go 56.88% <0.00%> (-7.04%) ⬇️
version/version.go 52.43% <0.00%> (-16.92%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a055fc3...7e8e5b9. Read the comment docs.

@@ -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") {
Copy link
Owner

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
Copy link
Owner

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 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 代码中内置一个镜像URL也并不太合适。通过环境变量读取一个自定义的镜像地址,已经足够应对中国大陆的网络需求,不想复杂化。

@voidint voidint merged commit d5553dc into voidint:master Aug 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants