Skip to content

Commit cd18079

Browse files
committed
Add --noout option to sympa command line (see sympa-community#1518)
1 parent 5b5d79b commit cd18079

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

src/lib/Sympa/CLI.pm

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use Sympa::Template;
4141
use Sympa::Tools::Data;
4242

4343
my $language = Sympa::Language->instance;
44+
my $noout;
4445

4546
sub run {
4647
my $class = shift;
@@ -113,7 +114,7 @@ sub run {
113114
} elsif (
114115
not Getopt::Long::GetOptionsFromArray(
115116
\@argv, \%options,
116-
qw(config|f=s debug|d lang|l=s log_level=s mail|m),
117+
qw(config|f=s debug|d lang|l=s log_level=s mail|m noout),
117118
$class->_options
118119
)
119120
) {
@@ -124,6 +125,8 @@ sub run {
124125
return undef;
125126
}
126127

128+
$noout = $options{noout};
129+
127130
# Get privileges and load config if necessary.
128131
# Otherwise only setup language if specified.
129132
$language->set_lang($options{lang}) if $options{lang};
@@ -406,7 +409,9 @@ sub _translate_warn {
406409
return $output;
407410
}
408411

409-
$SIG{__WARN__} = sub { warn _translate_warn(shift) };
412+
$SIG{__WARN__} = sub {
413+
warn _translate_warn(shift) unless $noout;
414+
};
410415

411416
my $arg_labels = {
412417
list => {gettext_id => 'list'},

src/lib/Sympa/CLI/bouncers/reset.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ sub _run {
5555
) {
5656
$users++;
5757
} else {
58-
printf STDERR "Unable to cancel bounce error for %s.\n", $i->{email};
58+
warn sprintf "Unable to cancel bounce error for %s.\n",
59+
$i->{email};
5960
}
6061
$errors++;
6162
}

src/lib/Sympa/CLI/config.pm

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ sub _run {
6565
only_changed => 1,
6666
filter => ([@{$options->{output} // []}, qw(explicit mandatory)])
6767
);
68-
return 1 unless defined $out;
68+
unless (defined $out) {
69+
warn "Not changed.\n";
70+
return 1;
71+
}
6972

7073
my $sympa_conf = Sympa::Constants::CONFIG();
7174
my $date = POSIX::strftime('%Y%m%d%H%M%S', localtime time);

src/lib/Sympa/CLI/dump.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ sub _run {
6565
}
6666
foreach my $role (@roles) {
6767
unless ($list->dump_users($role)) {
68-
printf STDERR "%s: Could not dump list users (%s)\n",
68+
warn sprintf "%s: Could not dump list users (%s)\n",
6969
$list->get_id, $role;
7070
} else {
71-
printf STDERR "%s: Dumped list users (%s)\n",
71+
warn sprintf "%s: Dumped list users (%s)\n",
7272
$list->get_id, $role;
7373
}
7474
}

src/lib/Sympa/CLI/lowercase.pm

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ sub _run {
4040
my $class = shift;
4141
my $options = shift;
4242

43-
print STDERR "Working on user_table...\n";
43+
warn "Working on user_table...\n";
4444
my $total = _lowercase_field('user_table', 'email_user');
4545

4646
if (defined $total) {
47-
print STDERR "Working on subscriber_table...\n";
47+
warn "Working on subscriber_table...\n";
4848
my $total_sub =
4949
_lowercase_field('subscriber_table', 'user_subscriber');
5050
if (defined $total_sub) {
@@ -57,7 +57,7 @@ sub _run {
5757
exit 1;
5858
}
5959

60-
printf STDERR "Total lowercased rows: %d\n", $total;
60+
warn sprintf "Total lowercased rows: %d\n", $total;
6161

6262
exit 0;
6363
}

src/lib/Sympa/CLI/restore.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ sub _run {
6565
}
6666
foreach my $role (@roles) {
6767
unless ($list->restore_users($role)) {
68-
printf STDERR "%s: Could not restore list users (%s)\n",
68+
warn sprintf "%s: Could not restore list users (%s)\n",
6969
$list->get_id, $role;
7070
} else {
71-
printf STDERR "%s: Restored list users (%s)\n",
71+
warn sprintf "%s: Restored list users (%s)\n",
7272
$list->get_id, $role;
7373
}
7474
}

src/sbin/sympa.pl.in

+6
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ Sets Sympa log level.
281281
282282
Enable SMTP logging.
283283
284+
=item C<--noout>
285+
286+
Skip output to the console except for fatal error messages.
287+
284288
=back
285289
286290
=head1 COMMANDS
@@ -921,4 +925,6 @@ F<sympa_msg.pl> daemon.
921925
As of Sympa 6.2.68, F<sympa.pl> was renamed to F<sympa>
922926
and the new form of command line arguments was introduced.
923927
928+
The C<--noout> option was introduced on Sympa 6.2.71b.
929+
924930
=cut

0 commit comments

Comments
 (0)