Posted By

birdspider on 08/16/10


Tagged

Bash cli clojure ProgressBar


Versions (?)

clojure progressbar bash


 / Published in: Clojure
 

first try, use with care

  1. (defn progress
  2. "prints a progressbar to shell, use repeatetly to 'update' the progressbar"
  3. [posV maxV & text]
  4. (let [ barmax 80
  5. multiplier (/ barmax maxV)
  6. pos_ (min (round (* posV multiplier)) barmax)
  7. start \[
  8. end \]
  9. left (apply str (repeat pos_ \=))
  10. right (apply str (repeat (- barmax pos_) \-))
  11. style \>
  12. msg (first text)]
  13. (binding [*out* *err*]
  14. (print (str "\r" start left style right end) msg) (flush))
  15.  
  16. )
  17. )

Report this snippet  

You need to login to post a comment.