progress 4.0.3

Easy progress reporting for D. There are Progress bar, Spinner, Counter and D-man.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

progress

Build Status Dub version Go to progress LICENSE

Easy progress reporting for D inspired by Python's one with the same name. There are 6 progress bar, 4 spinner, 4 counter, and... Dman.

Progress bar

  • Bar
  • ChargingBar
  • FillingSquaresBar
  • FillingCirclesBar
  • IncrementalBat
  • ShadyBar

Spinner

  • Spinner
  • PieSpinner
  • MoonSpinner
  • LineSpinner

Counter

  • Counter
  • Countdown
  • Stack
  • Pie

Dman

  • DmanSpinner

Usage

progress bars

Call next to advance and finish to finish.

Bar b = new Bar();
b.message = {return "Processing";};
b.max = 20;
foreach(i; 0 .. 20)
{
    //Do some work
    b.next();
}
b.finish();
Processing |##################              | 12/20

In the general case, you can use the iter method to write simply

import std.range : iter;

Bar b = new Bar();
foreach(i; b.iter(iota(20)) )
{
    //Do something
}

Progress bars are very customizable, you can change their width, their fill character, their suffix and more.

import std.conv : to;

b.message = {return "Loading";};
b.fill = '@';
b.suffix = {return b.percent.to!string ~ "%";};

This will produce a bar like the following:

Loading |@@@@@@@                         | 24%

There are various properties that can be used in message and suffix.

nametypevalue
indexsize_tcurrent value
maxsize_tmaximum value
remainingsize_tmax - index
progressrealindex / max
percentrealprogress * 100
avgDurationsimple moving average time per item
elapsedDurationelapsed time in seconds
etaDurationavg * remaining

Instead of passing all configuration options on instatiation, you can create your custom subclass:

class CustomBar : Bar
{
    this()
    {
        super();
        bar_prefix = "/";
        bar_suffix = "/";
        empty_fill = " ";
        fill = "/";
        suffix = {return "Custom";};
    }

You can also override any of the arguments or create your own:

class SlowBar : Bar
{
    this()
    {
        super();
        suffix = {return this.remaining_hours.to!string ~ "hours remaining";};
    }
    @property long remaining_hours()
    {
        return this.eta.total!"hours";
    }
}

Spinners

For actions with an unknown number of steps you can use a spinner:

import progress.spinner;

auto s = new Spinner();
s.message = {return "Loading";};
while (finished != true)
{
    //Do something
    s.next();
}

Counters

Counters can be used like progress bar. However, Counter is the same as spinners, and has no properties that require maximum value.

Dman

Same as spinners. it's very big.

Please see example projects and source if you want to learn more.

Authors: kotet

Dependencies: none

Versions:
4.0.3 2017-Apr-27
4.0.2 2017-Apr-25
4.0.1 2017-Apr-19
4.0.0 2017-Apr-19
3.0.1 2017-Apr-04
Show all 20 versions
Stats:
  • 1 downloads today

  • 2 downloads this week

  • 2 downloads this month

  • 55 downloads total