aaronpriven / actium

Programs used for schedules and other information at AC Transit
Other
1 stars 1 forks source link

Crier: percentage, time progress indicators #31

Open aaronpriven opened 7 years ago

aaronpriven commented 7 years ago

Crier allows all kinds of progress indicators, but it would be nice to have ones that would automatically deal with percentages and elapsed time.

1) Elapsed time -- Display progress indicator if and only if an amount of time has elapsed.

$cry->timed_prog(".");
# displays "." only if the default amount of time has passed since the last display
$cry->timed_over($count, { elapsed => 2 });
# displays "." only if 2 seconds have passed since the last display

2) Percentages -- Shortcuts for displaying percentage progress indicators.

$cry = $crier->percent_cry("Doing something...");
# displays "Doing something... 0%"
$cry->percent($count, $total);
# if it's been over the elapsed time, use ->over to display $count/$total as a percentage
$cry->done;
# does over(" 100%") and closes with "DONE". 
$cry->d_fatal;
# if the error level is high enough, skips closing percentage