Giter Site home page Giter Site logo

consolebars's Introduction

Pub Version (including pre-releases) GitHub last commit GitHub language count GitHub top language

A package for creating an awesome progress bar in the terminal. Handy while developing a CLI or a desktop utility in dart.

Usage

Options:

  • total : Total number of steps
  • desc : Simple text shown before the bar (optional)
  • space : Character denoting empty space (default : '.')
  • fill : Character denoting filled space (default : '█')
  • time : Toggle timing mode (default : false)
  • percentage : Toggle percentage display (default : false)
  • scale : Scale of the bar relative to width (between: 0 and 1, default: 0.5, Irrelavant if width is specified)
  • width : Width of the bar (If not specified, it will be automatically calculated using the terminal width and scale)

Code:

final p = FillingBar(desc: "Loading", total: 1000, time: true, percentage:true);
  for (var i = 0; i < 1000; i++) {
    p.increment();
    sleep(Duration(milliseconds: 10));
  }

Result:

Animation

Loading : ████████████████████████████████████████.................... 673/1000 67.3% [ 0:00:13.28 / 0:00:06.45 ]

Note: You can use the total and desc setters to change the total number of steps and description mid-way.

consolebars's People

Contributors

rohitedathil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

consolebars's Issues

time: true makes the whole thing just stop

Hi there!
I tried using your bar. Very nice!

However, if i set time: true, my code doesn't execute at all :/ all i see is the time being nicely updated

Maybe you wanted to update it per-second, messed something with streams, and that's why. How about, the time updating only when you call .increment() 👀 ?

Cheers

MacOs : StdoutException

Getting , Unhandled Exception: StdoutException: Could not get terminal size, OS Error: Inappropriate ioctl for device, errno = 25
on Macos M1

Allow total to be changed at runtime.

I have a progress bar where the total may change over time.

I propose a update to the API like so:

void update(int n) { ... }

to

void update(int n, {int? total}) { ... }

and then if I call update(1, total: 100) the total gets updated appropriately.

Alternatively there could be a new method to update the total, but it seems reasonable to always update the current progress and total at the same time.

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.