Closed peti closed 11 years ago
Take a look at the implementation of progressBar
:
putChar '\r'
putStr $ mkProgressBar mkPreLabel mkPostLabel width todo done
If you replace putChar
and putStr
with hPutChar
and hPutStr
you can easily write a progress bar to any file handle, such as stderr.
I'll see if I can add this functionality to the terminal-progress-bar
package in an elegant way.
Well, hacking the source code of the package is something I'd rather avoid, because if I do that then I can no longer re-use the package from Hackage as-is, but have to publish my own version instead.
In my humble opinion, it would be easiest to split the API into two parts:
If the code that does (1) were accessible to me, then I could easily write the progress bar to stderr, or display it on a web page, or do whatever I'd like to do without having to patch the source code of your library.
Duh, I just realize that mkProgessBar
does exactly what I need! Sorry for the noise.
I'd would like to add a progress bar to my program, but it needs the standard output channel to write resuts which are processed in a pipe, i.e. I need the progress bar to be displayed on
stderr
. Is that possible with your package?