@@ -183,16 +183,24 @@ my %TESTS = (
183
183
},
184
184
],
185
185
);
186
+ my %FORMATTER = (
187
+ text => \&summarize_results,
188
+ );
189
+
186
190
187
191
MAIN();
188
192
189
193
sub MAIN {
190
194
my %opt ;
191
- GetOptions(\%opt , ' help|h|?!' , ' man!' )
195
+ GetOptions(\%opt , ' help|h|?!' , ' man!' , ' format=s ' )
192
196
or pod2usage(-verbose => 0);
193
197
pod2usage(-verbose => 1) if $opt {help };
194
198
pod2usage(-verbose => 2) if $opt {man };
195
199
200
+ $opt {format } ||= ' text' ;
201
+ my $formatter = $FORMATTER {$opt {format }}
202
+ or pod2usage(-msg => " Unknown output format '$opt {format}'" );
203
+
196
204
my @results ;
197
205
198
206
eval {
@@ -202,7 +210,7 @@ sub MAIN {
202
210
};
203
211
warn " \n $@ \n " if $@ ;
204
212
205
- summarize_results (\@results );
213
+ $formatter -> (\@results );
206
214
}
207
215
208
216
sub run_tests {
@@ -426,7 +434,7 @@ bench -- Benchmark Perl-family compilers against each other
426
434
427
435
=head1 SYNOPSIS
428
436
429
- bench [--help|-h|-?] [--man]
437
+ bench [--help|-h|-?] [--man] [--format=text]
430
438
431
439
432
440
=head1 DESCRIPTION
@@ -455,6 +463,11 @@ Get basic help for this program
455
463
456
464
Display this program's entire manpage
457
465
466
+ =item --format=text
467
+
468
+ Format the summary output in a particular format. The default is 'text',
469
+ which outputs a text-rendered summary table, with ANSI coloring.
470
+
458
471
=back
459
472
460
473
0 commit comments