The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Text::ProgressBar - indicates the progress of a lengthy operation visually on your terminal

VERSION

Version 0.3

SYNOPSIS

    use Text::ProgressBar::Bar;

    my $pbar = Text::ProgressBar->new();
    $pbar->start();
    for my $i (1..100) {
        sleep 0.2;
        $pbar->update($i);
    }
    $pbar->finish;

DESCRIPTION

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]

SUBROUTINES/METHODS

BUILD

_handle_resize

Tries to catch resize signals sent from the terminal

setup_signal

handle terminal window resize events (transmitted via the WINCH signal)

_build_widgets

builder for all widgets - used by Moose

percentage

Returns the progress as a percentage

_format_widgets

format all widgets

_format_line

Joins the widgets and justifies the line

_need_update

Returns whether the ProgressBar should redraw the line

_update_widgets

Checks all widgets for the time sensitive bit

update

Updates the ProgressBar to a new value.

start

Starts measuring time, and prints the bar at 0%

finish

Puts the ProgressBar bar in the finished state.

AUTHOR

Farhad Fouladi, <farhad at cpan.org>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Text::ProgressBar

You can also look for information at:

ACKNOWLEDGEMENTS

'Nilton Volpato' for original idea

SEE ALSO

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

LICENSE AND COPYRIGHT

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.