NAME
Term::YAPI - Yet Another Progress Indicator
SYNOPSIS
use Term::YAPI;
my $prog = Term::YAPI->new('prog' => [ qw(/ - \ |) ]);
$prog->start('Working: ');
foreach (1..10) {
sleep(1);
$prog->progress();
}
$prog->done('done');
DESCRIPTION
Term::YAPI provides a simple progress indicator on the terminal to let the user know that something is happening. The indicator is an animation of single characters displayed cyclically one after the next.
The cursor is hidden while progress is being displayed, and restored after the progress indicator finishes. A $SIG{'INT'}
handler is installed while progress is being displayed so that the cursor is automatically restored should the user hit ctrl-C
.
- my $prog = Term::YAPI->new()
-
Creates a new progress indicator object, using the default twirling bar indicator: / - \ |
- my $prog = Term::YAPI->new('prog' => $indicator_array_ref)
-
Creates a new progress indicator object using the characters specified in the supplied array ref. Examples:
my $prog = Term::YAPI->new('prog' => [ qw(^ > v <) ]); my $prog = Term::YAPI->new('prog' => [ qw(. o O o) ]); my $prog = Term::YAPI->new('prog' => [ qw(. : | :) ]); my $prog = Term::YAPI->new('prog' => [ qw(9 8 7 6 5 4 3 2 1 0) ]);
- $prog->start($start_msg)
-
Sets up the interrupt signal handler, hides the cursor, and prints out the optional message string followed by the first progress character. The message defaults to 'Working: '.
- $prog->progress()
-
Backspaces over the previous progress character, and displays the next character.
- $prog->done($done_msg)
-
Prints out the optional message (defaults to 'done'), restores the cursor, and removes the interrupt handler installed by the
start
method (restoring any previous interrupt handler).
The progress indicator object is reusable.
INSTALLATION
The following will install YAPI.pm under the Term directory in your Perl installation:
cp YAPI.pm `perl -MConfig -e'print $Config{privlibexp}'`/Term/
SEE ALSO
AUTHOR
Jerry D. Hedden, <jdhedden AT cpan DOT org>
COPYRIGHT AND LICENSE
Copyright 2005, 2006 Jerry D. Hedden. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.