progress ~master

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


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

progress

D 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:
5.0.2 2022-May-03
5.0.1 2017-Dec-09
5.0.0 2017-Dec-06
4.0.5 2017-Nov-28
4.0.4 2017-Nov-28
Show all 25 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 28 downloads this month

  • 1008 downloads total

Score:
2.0
Short URL:
progress.dub.pm