Git Product home page Git Product logo

snck's Introduction

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

snck's People

Contributors

shigekikarita avatar

Stargazers

Ferhat Kurtulmuş avatar Shu Kakihana avatar Joakim Brännström avatar Rahul Nair avatar Koji Ono avatar  avatar Jan Jurzitza avatar Christian Köstlin avatar tanitta avatar

Watchers

James Cloos avatar  avatar  avatar

snck's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.