/cl-cram

A simple, Progress Bar for Common Lisp

Primary LanguageCommon LispMIT LicenseMIT

:cl-cram

A simple, progress bar for Common Lisp like tqdm!

demo

News

  • (2023/03/5) Here's my reimplementation of cl-cram at cl-tqdm.

cl-tqdm is Not yet registered in Quicklisp but it is recommended to use the new one. (cl-cram is registered)

Usage

;; in ./test.lisp

(load "cl-cram.lisp")
(use-package :cl-cram) ; or just (ql:quickload :cl-cram)

; You can line up several progress bars.
(init-progress-bar x "Loop1" 10000)
(init-progress-bar y "Loop2" 10000)
(init-progress-bar z "Loop3" 10000)

(fresh-line)

(dotimes (_ 10000)
  (update x 1) ; update a progress-bar
  (update y 1)
  (update z 1))

(fresh-line)

(discard-all-progress-bar) ; reset all of progress-bars

(sleep 1)

; with-progress-macro is more simple way to display it!
(with-progress-bar x "Loop1" 10000
  (dotimes (i 10000)
    (update x 1)))

(fresh-line)

Exports

(init-progress-bar var desc total) Initialize the ProgressBar Structure and assign it to var.

desc: description of progress bar

total: max of the iteration

(update status count) update the status, and display the new progress bar.

status: The structure to be updated as defined by the above macro

count: fixnum

(discard-all-progress-bar) Abandon all lists of the progress bar

*progress-bar-ascii* You can set the character string as you want to be displayed as the meter. For example...

(setq *progress-bar-ascii* "#")

*blank* example -> (setq *blank* " ")

*progress-bar-enabled* when *progress-bar-enabled* equals nil, no new line will be created.

with-progress-bar Please refer to examples.

Macros

(pdotimes (i 10)
    (sleep 0.1))

(pdolist (i `(1 2 3 4 5))
    (sleep 0.1))
    
(pmap 'list #'(lambda (x) (sleep 0.1) x) `(1 2 3 4 5))