parallel: Fixed unknown option bug. Renamed --etas to --bar.

This commit is contained in:
Ole Tange 2013-11-01 12:08:38 +01:00
parent 4fa5c872bc
commit f1a40b3aff

View file

@ -702,7 +702,7 @@ sub options_hash {
"dry-run|dryrun" => \$opt::dryrun, "dry-run|dryrun" => \$opt::dryrun,
"progress" => \$opt::progress, "progress" => \$opt::progress,
"eta" => \$opt::eta, "eta" => \$opt::eta,
"etas" => \$opt::etas, "bar" => \$opt::bar,
"arg-sep|argsep=s" => \$opt::arg_sep, "arg-sep|argsep=s" => \$opt::arg_sep,
"arg-file-sep|argfilesep=s" => \$opt::arg_file_sep, "arg-file-sep|argfilesep=s" => \$opt::arg_file_sep,
"trim=s" => \$opt::trim, "trim=s" => \$opt::trim,
@ -785,12 +785,12 @@ sub get_options_from_array {
$options{$k} = \@dummy; $options{$k} = \@dummy;
} }
} }
my @retval = GetOptions(%options); my $retval = GetOptions(%options);
if(not $this_is_ARGV) { if(not $this_is_ARGV) {
@{$array_ref} = @::ARGV; @{$array_ref} = @::ARGV;
@::ARGV = @save_argv; @::ARGV = @save_argv;
} }
return @retval; return $retval;
} }
sub parse_options { sub parse_options {
@ -1023,8 +1023,8 @@ sub parse_options {
if(defined $opt::eta) { if(defined $opt::eta) {
$opt::progress = $opt::eta; $opt::progress = $opt::eta;
} }
if(defined $opt::etas) { if(defined $opt::bar) {
$opt::progress = $opt::etas; $opt::progress = $opt::bar;
} }
if(defined $opt::retired) { if(defined $opt::retired) {
::error("-g has been retired. Use --group.\n"); ::error("-g has been retired. Use --group.\n");
@ -1651,7 +1651,7 @@ sub init_progress {
# Returns: # Returns:
# list of computers for progress output # list of computers for progress output
$|=1; $|=1;
if($opt::etas) { if($opt::bar) {
return("",""); return("","");
} }
my %progress = progress(); my %progress = progress();
@ -1740,7 +1740,7 @@ sub progress {
} }
my $eta = ""; my $eta = "";
my ($status,$header)=("",""); my ($status,$header)=("","");
if($opt::eta or $opt::etas) { if($opt::eta or $opt::bar) {
my $completed = 0; my $completed = 0;
for(@workers) { $completed += $Global::host{$_}->jobs_completed() } for(@workers) { $completed += $Global::host{$_}->jobs_completed() }
if($completed) { if($completed) {
@ -1764,23 +1764,23 @@ sub progress {
$this_eta = $Private::last_eta; $this_eta = $Private::last_eta;
} }
$eta = sprintf("ETA: %ds %dleft %.2favg ", $this_eta, $left, $avgtime); $eta = sprintf("ETA: %ds %dleft %.2favg ", $this_eta, $left, $avgtime);
if($opt::etas) { if($opt::bar) {
my $arg = $Global::newest_job ? my $arg = $Global::newest_job ?
$Global::newest_job->{'commandline'}->simple_replace_placeholders($Global::replace{"{}"}) : ""; $Global::newest_job->{'commandline'}->simple_replace_placeholders($Global::replace{"{}"}) : "";
my $etas = sprintf("%d%% %ds %s", $pctcomplete*100, $this_eta, $arg); my $bar = sprintf("%d%% %ds %s", $pctcomplete*100, $this_eta, $arg);
my $rev = ''; my $rev = '';
my $reset = ''; my $reset = '';
my $terminal_width = terminal_columns(); my $terminal_width = terminal_columns();
my $s = sprintf("%-${terminal_width}s",$etas); my $s = sprintf("%-${terminal_width}s",$bar);
my $width = int($terminal_width * $pctcomplete); my $width = int($terminal_width * $pctcomplete);
$s =~ s/^(.{$width})/$1$reset/; $s =~ s/^(.{$width})/$1$reset/;
$s = "\r# ".int($this_eta)." sec $arg" . "\r". $pctcomplete*100 # Prefix with zenity header $s = "\r# ".int($this_eta)." sec $arg" . "\r". $pctcomplete*100 # Prefix with zenity header
. "\r" . $rev . $s; . "\r" . $rev . $s . $reset;
$status = $s; $status = $s;
} }
} }
} }
if($opt::etas) { if($opt::bar) {
return ("workerlist" => "", "header" => "", "status" => $status); return ("workerlist" => "", "header" => "", "status" => $status);
} }
$status = "x"x($termcols+1); $status = "x"x($termcols+1);