summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
index 6baf91e1b17..3319f68a6ba 100644
--- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
+++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: ProgressMeter.pm,v 1.33 2010/06/05 12:01:08 espie Exp $
+# $OpenBSD: ProgressMeter.pm,v 1.34 2010/06/18 09:01:38 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@@ -46,6 +46,21 @@ sub errprint
print STDERR @_;
}
+sub for_list
+{
+ my ($self, $msg, $l, $code) = @_;
+ if (defined $msg) {
+ $self->set_header($msg);
+ }
+ my $total = scalar @$l;
+ my $i = 0;
+ for my $e (@$l) {
+ $self->show(++$i, $total);
+ &$code($e);
+ }
+ $self->next;
+}
+
# stub class when no actual progressmeter that still prints out.
package OpenBSD::ProgressMeter::Stub;
our @ISA = qw(OpenBSD::ProgressMeter);