Skip to content

Commit 79f94f4

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

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

src/lib/Sympa/CLI.pm

+30-22
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};
@@ -347,26 +350,29 @@ sub _report {
347350
my $class = shift;
348351
my $spindle = shift;
349352

350-
my @reports = @{$spindle->{stash} || []};
351-
@reports = ([undef, 'notice', 'performed']) unless @reports;
352-
353-
my $template = Sympa::Template->new('*', subdir => 'mail_tt2');
354-
foreach my $report (@reports) {
355-
my ($request, $report_type, $report_entry, $report_param) = @$report;
356-
my $action = $request ? $request->{action} : 'sympa';
357-
my $message = '';
358-
$template->parse(
359-
{ report_type => $report_type,
360-
report_entry => $report_entry,
361-
report_param => ($report_param || {}),
362-
},
363-
'report.tt2',
364-
\$message
365-
);
366-
$message ||= $report_entry;
367-
$message =~ s/\n/ /g;
368-
369-
warn sprintf "%s [%s] %s\n", $action, $report_type, $message;
353+
unless ($noout) {
354+
my @reports = @{$spindle->{stash} || []};
355+
@reports = ([undef, 'notice', 'performed']) unless @reports;
356+
357+
my $template = Sympa::Template->new('*', subdir => 'mail_tt2');
358+
foreach my $report (@reports) {
359+
my ($request, $report_type, $report_entry, $report_param) =
360+
@$report;
361+
my $action = $request ? $request->{action} : 'sympa';
362+
my $message = '';
363+
$template->parse(
364+
{ report_type => $report_type,
365+
report_entry => $report_entry,
366+
report_param => ($report_param || {}),
367+
},
368+
'report.tt2',
369+
\$message
370+
);
371+
$message ||= $report_entry;
372+
$message =~ s/\n/ /g;
373+
374+
warn sprintf "%s [%s] %s\n", $action, $report_type, $message;
375+
}
370376
}
371377

372378
return $spindle->success ? 1 : undef;
@@ -406,7 +412,9 @@ sub _translate_warn {
406412
return $output;
407413
}
408414

409-
$SIG{__WARN__} = sub { warn _translate_warn(shift) };
415+
$SIG{__WARN__} = sub {
416+
warn _translate_warn(shift) unless $noout;
417+
};
410418

411419
my $arg_labels = {
412420
list => {gettext_id => 'list'},

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/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)