alexellis / arkade

Open Source Marketplace For Developer Tools
https://blog.alexellis.io/kubernetes-marketplace-two-year-update/
MIT License
4.25k stars 289 forks source link

Add a progress bar to the download message #189

Closed rberrelleza closed 4 years ago

rberrelleza commented 4 years ago

It would be useful to have a progress bar when arkade is downloading a binary.

Expected Behaviour

When a binary is being downloaded, arkade could show the speed, size and percentage of completion.

Current Behaviour

Today, nothing is shown. For large binaries, it's hard to tell if the download is working on ot.

Possible Solution

At okteto, we've had success using https://github.com/cheggaaa/pb/ for this

tuananh commented 4 years ago

@rberrelleza is there an example how to hook it with Http client?

rberrelleza commented 4 years ago

@tuananh I wrote a quick one here based on how we use it in okteto: https://gist.github.com/rberrelleza/29daea3dffd20e7a28dd8948b4c2cfbc

rberrelleza commented 4 years ago

another option could be to use https://github.com/hashicorp/go-getter. Which is something we could even use more broadly, since it automatically deals with unzipping and things like that.

tuananh commented 4 years ago

@alexellis what's your thought on this?

alexellis commented 4 years ago

Which specific binaries were causing you to question whether the command worked?

I don't know if I'm spoiled with 100mbps internet, but I've not seen this as a concern so far and know how tricky animations become once applied to CI / headless scripts / Jenkins etc..

rberrelleza commented 4 years ago

@alexellis it happened with kubectl. I installed it this morning and it took 8-12 seconds, without any output. Maybe is just my internet that is slow 🤷

alexellis commented 4 years ago

AFAIK over 7s without new output is where humans get worried that it's broken.

We could do a CI-friendly printing . every 500 ms, or checkout your suggested progress bar.

I also put something together a little while ago https://github.com/alexellis/cli-progress-animation

I remember issues with CI being a problem, along with issues with Windows and cmd.exe.

There may be some way to detect if it's a proper terminal and then not print output, or only print dots?

alexellis commented 4 years ago

I just tried out your gist @rberrelleza - it looks nice.

Do you know why it didn't "complete" though?

kosmos:29daea3dffd20e7a28dd8948b4c2cfbc alex$ go run main.go 
55.94 MB / 58.50 MB [------------------------------------------------>__] 95.63%kosmos:29daea3dffd20e7a28dd8948b4c2cfbc alex$ 
alexellis commented 4 years ago

The second run was a little different too

kosmos:29daea3dffd20e7a28dd8948b4c2cfbc alex$ go run main.go 
2020/08/29 10:18:48 Total 58498048
58.11 MB / 58.50 MB [----------------------------------------------------------------------------------------------------------------------------------->] 99.33%2020/08/29 10:18:54 Total p 58498048
kosmos:29daea3dffd20e7a28dd8948b4c2cfbc alex$ 
rberrelleza commented 4 years ago

@alexellis i's most likely finishing the writing before the animation is done. In okteto we added a check at the end to give it smother experience.

alexellis commented 4 years ago

@rberrelleza would you send a PR for this? There should also be some kind of env-var to turn it off like ARKADE_PROGRESS=0

rberrelleza commented 4 years ago

Yep, assign the ticket to me.

alexellis commented 4 years ago

Can't assign it to you, but feel free to PR like the gist.