summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-06-05 12:01:09 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-06-05 12:01:09 +0000
commit44a26200b68b16ae2449fb346e09dd6da54302db (patch)
tree61e5d5d6b382a14afc662c210fc8041aeabd065d /usr.sbin
parent1590480564f47ed7e550f7e776408387a98e6bf8 (diff)
interface tweaks:
- allow mtree to create more diverse data structures. - new "working" method, for when progressmeter should show that something is going on, but doesn't actually have an actual % to show, so show cartwheels. e.g., progress->working(1024); (actual counter will be /= argument, so that it does move a bit slower).
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Mtree.pm14
-rw-r--r--usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm9
3 files changed, 19 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Mtree.pm b/usr.sbin/pkg_add/OpenBSD/Mtree.pm
index fe2a774e7dd..40687d171d3 100644
--- a/usr.sbin/pkg_add/OpenBSD/Mtree.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Mtree.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Mtree.pm,v 1.7 2010/05/10 09:17:55 espie Exp $
+# $OpenBSD: Mtree.pm,v 1.8 2010/06/05 12:01:08 espie Exp $
#
# Copyright (c) 2004-2005 Marc Espie <espie@openbsd.org>
#
@@ -25,7 +25,7 @@ use File::Spec;
sub parse_fh
{
- my ($mtree, $basedir, $fh) = @_;
+ my ($mtree, $basedir, $fh, $h) = @_;
my $_;
while(<$fh>) {
chomp;
@@ -43,15 +43,19 @@ sub parse_fh
}
$_ = $basedir;
while (s|/\./|/|o) {}
- $mtree->{File::Spec->canonpath($_)} = 1;
+ if (defined $h) {
+ $mtree->{File::Spec->canonpath($_)} //= {};
+ } else {
+ $mtree->{File::Spec->canonpath($_)} = 1;
+ }
}
}
sub parse
{
- my ($mtree, $basedir, $filename) = @_;
+ my ($mtree, $basedir, $filename, $h) = @_;
open my $file, '<', $filename or die "can't open $filename: $!";
- parse_fh($mtree, $basedir, $file);
+ parse_fh($mtree, $basedir, $file, $h);
close $file;
}
diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter.pm
index 458aa06cd08..6baf91e1b17 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.32 2010/06/04 13:19:39 espie Exp $
+# $OpenBSD: ProgressMeter.pm,v 1.33 2010/06/05 12:01:08 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@@ -54,6 +54,7 @@ sub clear {}
sub show {}
+sub working {}
sub message {}
sub next {}
diff --git a/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm b/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm
index 72f0490c6a3..5ea68ee23e0 100644
--- a/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm
+++ b/usr.sbin/pkg_add/OpenBSD/ProgressMeter/Term.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Term.pm,v 1.4 2010/06/04 13:19:39 espie Exp $
+# $OpenBSD: Term.pm,v 1.5 2010/06/05 12:01:08 espie Exp $
#
# Copyright (c) 2004-2007 Marc Espie <espie@openbsd.org>
#
@@ -64,6 +64,7 @@ sub init
$self->find_window_size;
$self->{lastdisplay} = '';
$self->{continued} = 0;
+ $self->{work} = 0;
return unless defined $ENV{TERM} || defined $ENV{TERMCAP};
my $termios = POSIX::Termios->new;
$termios->getattr(0);
@@ -205,6 +206,12 @@ sub show
}
}
+sub working
+{
+ my ($self, $slowdown) = @_;
+ $self->{work}++;
+ $self->message(substr("/-\\|", ($self->{work}/$slowdown) % 4, 1));
+}
sub clear
{
my $self = shift;