Text::ProgressBar - indicates the progress of a lengthy operation visually on your terminal
Version 0.3
use Text::ProgressBar::Bar; my $pbar = Text::ProgressBar->new(); $pbar->start(); for my $i (1..100) { sleep 0.2; $pbar->update($i); } $pbar->finish;
The Text::ProgressBar is customizable, you can specify different kinds of widgets so as you can create your own widget. It is also possible that you combine more than one widget to find your own style.
The printing (output ascii) characters can also be modified and changed. A default set is defined for each widget, but user can change them during calling constructor or later by calling the corresponding methods (see individual widget).
Each 'widget' draws a different text on the screen. For an example for each 'widget' see its class POD!
When implementing your own widget, you create an update method and pass a reference current object of ProgressBar to it. As a result, you have access to the ProgressBar methods and attributes.
Following 'widgets' (class inheritance structure illustrated) are currently implemented. They can be used or extended or a new widgets can be created similar to them.
Widget |-- AnimatedMarker |-- Counter |-- FileTransferSpeed |-- Percentage |-- SimpleProgress |-- Timer | |-- ETA | `-- FormatLabel `-- WidgetHFill `-- Bar |-- BouncingBar `-- ReverseBar
Useful methods and attributes include (Public API):
term_width : current terminal width, if it is given, it sets the terminal width, otherwise actual terminal length will be get from system
currval: current progress (0 <= currval <= maxval)
maxval: maximum (and final) value
finished: True if the bar has finished (reached 100%)
start_time: the time when start() method of ProgressBar was called
seconds_elapsed: seconds elapsed since start_time and last call to update
percentage: progress in percent [0..100]
Tries to catch resize signals sent from the terminal
handle terminal window resize events (transmitted via the WINCH signal)
builder for all widgets - used by Moose
Returns the progress as a percentage
format all widgets
Joins the widgets and justifies the line
Returns whether the ProgressBar should redraw the line
Checks all widgets for the time sensitive bit
Updates the ProgressBar to a new value.
Starts measuring time, and prints the bar at 0%
Puts the ProgressBar bar in the finished state.
Farhad Fouladi, <farhad at cpan.org>
<farhad at cpan.org>
Please report any bugs or feature requests to bug-text-progressbar at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-ProgressBar. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-text-progressbar at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Text::ProgressBar
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Text-ProgressBar
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Text-ProgressBar
CPAN Ratings
http://cpanratings.perl.org/d/Text-ProgressBar
Search CPAN
http://search.cpan.org/dist/Text-ProgressBar/
'Nilton Volpato' for original idea
There are many 'ProgressBar' in CPAN written in Perl. But only through this module user can choose from a set of different 'widgets' in different forms and behaviours and addititionally combine these widgets to make a nicer output.
There are currently a good number of widgets, you can put them in any type in any order, but you can write your own widget. A new user-defined widget can be easily implemented. Herefor user can add a new subclass of existing widgets and add his own widget with new functionalities in it.
This module support resizing of terminal during execution, not all other 'ProgressBar' module support that.
Some of the other modules:
Smart::Comments, Term::ProgressBar, Term::Spinner, String::ProgressBar, ProgressBar::Stack
Copyright 2012 Farhad Fouladi.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Text::ProgressBar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::ProgressBar
CPAN shell
perl -MCPAN -e shell install Text::ProgressBar
For more information on module installation, please visit the detailed CPAN module installation guide.