Code Monkey home page Code Monkey logo

Comments (3)

mxie avatar mxie commented on June 15, 2024

Thanks for your suggestion!

Can you tell us more about what kind of progress indicator would be helpful? What kind of information would you like with it?

from cli.

MC-XiaoHei avatar MC-XiaoHei commented on June 15, 2024

thanks
I hope to be similar to this, providing a progress bar, a percentage, I think this can better alleviate the user 's waiting anxiety.

Downloading aaa plugin
[xxxxxxxxxxxxx------------------] 43%

or maybe others have better idea

from cli.

williammartin avatar williammartin commented on June 15, 2024

The code right now isn't really structured to support this very well but it's definitely a reasonable enhancement request. Most likely what we'd want to do is set up a progress bar based on the resp.ContentLength field and then as we read the resp.Body into the file we also tee it into the progress bar so that it can fill.

var resp *http.Response
if resp, downloadErr = httpClient.Do(req); downloadErr != nil {
return
}
defer resp.Body.Close()
if resp.StatusCode > 299 {
downloadErr = api.HandleHTTPError(resp)
return
}
var f *os.File
if f, downloadErr = os.OpenFile(destPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755); downloadErr != nil {
return
}
defer func() {
if err := f.Close(); downloadErr == nil && err != nil {
downloadErr = err
}
}()
_, downloadErr = io.Copy(f, resp.Body)

If we did this, we'd also want to consider accessibility. The current spinner is pretty bad because screen readers read a bunch of dots but if we're going to do the work to implement a real file download progress bar we'd want to treat accessibility as a first class concern.

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.