Skip to content

Commit

Permalink
Merge pull request #1568 from ikedas/issue-1567
Browse files Browse the repository at this point in the history
sympa instantiate: Progress bar could not be inactivated
  • Loading branch information
racke authored Dec 12, 2023
2 parents d6a4530 + 9451324 commit 113b488
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/lib/Sympa/CLI/instantiate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use Sympa::Spindle::ProcessRequest;

use parent qw(Sympa::CLI);

use constant _options => qw(close-unknown input-file=s quiet);
use constant _options => qw(close-unknown input-file=s);
use constant _args => qw(family);

my $log = Sympa::Log->instance;
Expand All @@ -61,7 +61,7 @@ sub _run {
$family,
$options->{input_file},
close_unknown => $options->{close_unknown},
quiet => $options->{quiet},
noout => ($options->{noout} or not $class->istty(2)),
)
) {
print STDERR "\nImpossible family instantiation : action stopped \n";
Expand All @@ -71,7 +71,7 @@ sub _run {
my %result;
my $err = get_instantiation_results($family, \%result);

unless ($options->{quiet}) {
unless ($options->{noout}) {
print STDOUT "@{$result{'info'}}";
print STDOUT "@{$result{'warn'}}";
}
Expand Down Expand Up @@ -130,7 +130,8 @@ sub instantiate {
$progress = Term::ProgressBar->new(
{ name => 'Creating lists',
count => $total,
ETA => 'linear'
ETA => 'linear',
silent => $options{noout},
}
);
$progress->max_update_rate(1);
Expand Down Expand Up @@ -201,8 +202,8 @@ sub instantiate {
$list->{'name'}, $created, $total
)
);
$next_update = $progress->update($created)
if ($created > $next_update);
$next_update = $progress->update($created) // 0
if $created > $next_update;
}

$progress->update($total) if $progress;
Expand Down Expand Up @@ -606,13 +607,13 @@ sympa-instantiate - Instantiate the lists in a family
=head1 SYNOPSIS
C<sympa instantiate> C<--input-file=>I</path/to/file.xml> [ C<--close-unknown> ] [ C<--quiet> ] I<family>C<@@>I<domain>
C<sympa instantiate> C<--input-file=>I</path/to/file.xml> [ C<--close-unknown> ] [ C<--noout> ] I<family>C<@@>I<domain>
=head1 DESCRIPTION
Instantiate the lists described in the file.xml in specified family.
The family directory must exist; automatically close undefined lists in a
new instantiation if C<--close_unknown> is specified; do not print report if
C<--quiet> is specified.
C<--noout> is specified.
=cut
3 changes: 2 additions & 1 deletion src/sbin/sympa.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ if ($options{'add'}) {
exit 1;
} elsif ($options{'instantiate_family'}) {
Sympa::CLI->run(
\%options, 'instantiate',
{%options, ($options{quiet} ? (noout => 1) : ())},
'instantiate',
sprintf '%s@@%s',
$options{instantiate_family},
$options{robot} || $Conf::Conf{'domain'}
Expand Down

0 comments on commit 113b488

Please sign in to comment.