snck 0.0.4

progress display


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:

snck

Dub version

snck is a port of tdqm in D. snck is an acronym of "Shi-N-Cho-Ku" that means "progress" in Japanese.

usage

import snck : snck;
import std.range;
import core.thread;

void main() {
  foreach (i; iota(3).snck) {
    Thread.sleep(dur!"seconds"(1));
  }
}

this code prints progress of foreach into stderr as follows:

 33%: 1/3|████      | [00:01<00:02, 1.00it/s]
 66%: 2/3|███████   | [00:02<00:01, 1.00it/s]
100%: 3/3|██████████| [00:03<00:00, 1.00it/s]

advanced usage

you can tweak any configurations in

struct SnckConf {
    double minSeconds = 0.1;
    bool showPercent = true;
    bool showCounter = true;
    bool showProgressBar = true;
    size_t barBlocks = 10;
    bool showElapsedTime = true;
    bool showETA = true;
    bool showSpeed = true;
    bool eraseLast = true;
}

for example

// using struct
SnckConf conf = {
  barBlocks: 20,     // more long progress bar
  minSeconds: 0.001, // more frequent updates
  eraseLast: false   // do not erase finished last stats
};

foreach (i; iota(2000).snck(conf).output(stdout)) {
  Thread.sleep(dur!"msecs"(1));
}

// using .set
foreach (i; iota(2000).snck
  .set!"barBlocks"(20)
  .set!"minSeconds"(0.001)
  .set!"eraseLast"(true)
  .output(stdout)) {
  Thread.sleep(dur!"msecs"(1));
}

TODO

  • support types using opApply
  • add unit tests
Authors:
  • Shigeki Karita
Dependencies:
none
Versions:
0.0.4 2018-May-06
0.0.3 2018-May-04
0.0.2 2018-May-04
0.0.1 2018-May-03
~master 2018-May-06
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 1475 downloads total

Score:
0.8
Short URL:
snck.dub.pm