add docs and total() accessor
This commit is contained in:
parent
69bd44b03d
commit
cbb8c0ed61
1 changed files with 29 additions and 0 deletions
|
|
@ -193,6 +193,25 @@ sub update {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 total ( newTotal )
|
||||
|
||||
Set the total number of tasks that need to be run. You should set this
|
||||
before running any actual tasks. If this is not set, the progress bar
|
||||
will not progress (though any update messages will still display to
|
||||
the user).
|
||||
|
||||
=cut
|
||||
|
||||
sub total {
|
||||
my ( $self, $newTotal ) = @_;
|
||||
if ( $newTotal ) {
|
||||
return $self->{_total} = $newTotal;
|
||||
}
|
||||
return $self->{_total};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 run ( options )
|
||||
|
||||
starts and finishes a progress bar, running some code in the middle. It
|
||||
|
|
@ -202,6 +221,15 @@ should return 'chunked' yourself.
|
|||
The following keyword arguments are accepted (either as a bare hash or a
|
||||
hashref).
|
||||
|
||||
=head3 total
|
||||
|
||||
Set the total number of tasks that need to be run. Every call to update() is
|
||||
another task completed. The progressbar works with percentages, so this
|
||||
must be set before any tasks are started.
|
||||
|
||||
If you need to calculate the number of tasks, be sure to set total() inside
|
||||
the C<code> subref before doing any actual work.
|
||||
|
||||
=head3 code
|
||||
|
||||
A coderef to run in between starting and stopping the progress bar. It is
|
||||
|
|
@ -251,6 +279,7 @@ sub run {
|
|||
my $wrap = $args->{wrap};
|
||||
|
||||
$self->start($args->{title}, $args->{icon});
|
||||
$self->{_total} = $args->{total};
|
||||
|
||||
my $url = eval {
|
||||
for my $name (keys %$wrap) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue