aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-05-25 11:01:15 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-05-25 11:10:17 +0300
commit8511d64e0627fe7235c065d9c3af30f1bff7355c (patch)
tree4b8fd380ed475b63fcacd846b8ab222dabe06ed3
parentde6a3ad4fb4fc61bfa97cd2a7cb902248200448a (diff)
downloadglacier-8511d64e0627fe7235c065d9c3af30f1bff7355c.tar.gz
glacier-8511d64e0627fe7235c065d9c3af30f1bff7355c.tar.bz2
Improve progress meter for single uploads.
* lib/App/Glacier/Progress.pm (new): New options: show_dots and show_none * lib/App/Glacier/Command/Put.pm (_upload_simple): Use show_none
-rw-r--r--lib/App/Glacier/Command/Put.pm2
-rw-r--r--lib/App/Glacier/Progress.pm18
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/App/Glacier/Command/Put.pm b/lib/App/Glacier/Command/Put.pm
index 11070bb..d08f07f 100644
--- a/lib/App/Glacier/Command/Put.pm
+++ b/lib/App/Glacier/Command/Put.pm
@@ -159,7 +159,7 @@ sub _upload_simple {
my $p = new App::Glacier::Progress(1,
prefix => $localname,
- show_percent => 1)
+ show_none => 1)
unless $self->{_options}{quiet};
my $archive_id = $self->glacier_eval('upload_archive',
$vaultname,
diff --git a/lib/App/Glacier/Progress.pm b/lib/App/Glacier/Progress.pm
index 3da6eca..39b892b 100644
--- a/lib/App/Glacier/Progress.pm
+++ b/lib/App/Glacier/Progress.pm
@@ -37,6 +37,14 @@ sub new {
$self->{_show_percent} = $v;
$show_default = 0;
}
+ if ($v = delete $opts{show_dots}) {
+ $self->{_show_dots} = $v;
+ $show_default = 0;
+ }
+ if ($v = delete $opts{show_none}) {
+ $show_default = 0;
+ }
+
croak "extra arguments" if keys %opts;
if ($show_default) {
@@ -90,6 +98,7 @@ sub display {
my ($self) = @_;
return unless defined $self->{_tty};
my $text = '';
+
if ($self->{_show_current}) {
$text .= sprintf("%*d", $self->{_digits}, $self->{_current});
}
@@ -102,6 +111,15 @@ sub display {
$text .= sprintf("%3d%%", int(100 * $self->{_current} / $self->{_total}));
}
$text = $self->{_prefix} . ': ' . $text if $self->{_prefix};
+
+ if ($self->{_show_dots}) {
+ my $w = $self->_getwidth;
+ if ($w > length($text)) {
+ $w -= length($text) + 2;
+ $text .= '.' x int($self->{_current} / $self->{_total} * $w);
+ }
+ }
+
$text .= ' ' x ($self->_getwidth - length($text));
my $fd = $self->{_tty};
print $fd "\r$text";

Return to:

Send suggestions and report system problems to the System administrator.