Module progress

Types

ProgressBar* = ref ProgressBarObj
ProgressBarObj* = object
  complete: string
  incomplete: string
  step: int
  width: int
  total: int
  current: int
A progress bar with a given length and step
InvalidPositionError* = object of Exception

Procs

proc newProgressBar*(total: int = 100; step: int = 1; width: int = 100;
                    complete: string = COMPLETE_STR;
                    incomplete: string = INCOMPLETE_STR): ProgressBar
Create a new progress bar with a given total, step and width.
proc isComplete*(pb: ProgressBar): bool
Check whether the progress bar is complete.
proc isIncomplete*(pb: ProgressBar): bool
Check whether the progress bar is incomplete.
proc percent*(pb: ProgressBar): float
Get the progress bar's current completion percentage.
proc start*(pb: ProgressBar) {.tags: [WriteIOEffect].}
Start the progress bar. This will write the empty (0%) bar to the screen, which may not always be desired.
proc tick*(pb: ProgressBar; count: int) {.raises: [IOError], tags: [WriteIOEffect].}
Increment the progress bar by count places.
proc increment*(pb: ProgressBar) {.raises: [IOError], tags: [WriteIOEffect].}
Increment the progress bar by one step.
proc set*(pb: ProgressBar; pos: int) {.raises: [InvalidPositionError, IOError],
                                  tags: [WriteIOEffect].}
Set the progress bar's current position to pos.
proc finish*(pb: ProgressBar) {.raises: [InvalidPositionError, IOError],
                             tags: [WriteIOEffect].}
Set the progress bar's current position to completion.