The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

Version 0.2

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 ProgressBar is customizable, you can specify different kinds of widgets so as you can create your own 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 Python module

BACKGROUND

I had implemented in Python before I began with Perl. As I started with Perl and later with Moose, I drew on my old habits and translated some of them to Perl. For example ideas of this module I borrowed 'shamelessly' from 'python- progressbar'.

There are many 'ProgressBar' in CPAN written in Perl. But only this module use 'Moose' as its OO-Vehicle.

SEE ALSO

Some of the finest:

Smart::Comments - For more helpful comments during debugging. But it's a source filter.

Term::ProgressBar - a progress bar on the terminal

Term::Spinner - A progress spinner for commandline programs

String::ProgressBar - Produces a simple progress bar

ProgressBar::Stack - creates a framework for adding progress bars to processes

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.