Search code examples
shake-build-system

Seeing console progress messages in Shake


I am using Shake, calling wget to download a file. If I do that on the command line I see a one-line progress bar, but when called from Shake I see many lines of dots. As an example:

shake shakeOptions $
    action
       (cmd "wget http://hackage.haskell.org/packages/index.tar.gz" :: Action ())

I would like that to show the one-line progress bar.


Solution

  • The solution is:

    shake shakeOptions{shakeLineBuffering=False} $
        action
            (cmd "wget http://hackage.haskell.org/packages/index.tar.gz --progress=bar:force" :: Action ())
    

    There are two things going on here:

    1) wget detects that it isn't sending direct to the console (since cmd captures output using pipes), and turns off the progress bar. With wget, you can turn that back on with --progress=bar:force.

    2) Once I've done that, the progress bar doesn't actually display, because Shake turns on line buffering by default (it helps commands run in parallel show less interleaved output) and a progress bar only updates within one line. You can fix that by setting the option shakeLineBuffering=False.