|
4 | 4 | use strict;
|
5 | 5 | use warnings;
|
6 | 6 | use JSON;
|
| 7 | +use Getopt::Long; |
7 | 8 | use Git;
|
8 | 9 |
|
9 | 10 | sub get_times {
|
@@ -36,46 +37,34 @@ sub format_times {
|
36 | 37 | return $out;
|
37 | 38 | }
|
38 | 39 |
|
| 40 | +sub usage { |
| 41 | + print <<EOT; |
| 42 | +./aggregate.perl [options] [--] [<dir_or_rev>...] [--] [<test_script>...] > |
| 43 | +
|
| 44 | + Options: |
| 45 | + --codespeed * Format output for Codespeed |
| 46 | + --reponame <str> * Send given reponame to codespeed |
| 47 | + --sort-by <str> * Sort output (only "regression" criteria is supported) |
| 48 | + --subsection <str> * Use results from given subsection |
| 49 | +
|
| 50 | +EOT |
| 51 | + exit(1); |
| 52 | +} |
| 53 | + |
39 | 54 | my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
|
40 | 55 | $codespeed, $sortby, $subsection, $reponame);
|
| 56 | + |
| 57 | +Getopt::Long::Configure qw/ require_order /; |
| 58 | + |
| 59 | +my $rc = GetOptions("codespeed" => \$codespeed, |
| 60 | + "reponame=s" => \$reponame, |
| 61 | + "sort-by=s" => \$sortby, |
| 62 | + "subsection=s" => \$subsection); |
| 63 | +usage() unless $rc; |
| 64 | + |
41 | 65 | while (scalar @ARGV) {
|
42 | 66 | my $arg = $ARGV[0];
|
43 | 67 | my $dir;
|
44 |
| - if ($arg eq "--codespeed") { |
45 |
| - $codespeed = 1; |
46 |
| - shift @ARGV; |
47 |
| - next; |
48 |
| - } |
49 |
| - if ($arg =~ /--sort-by(?:=(.*))?/) { |
50 |
| - shift @ARGV; |
51 |
| - if (defined $1) { |
52 |
| - $sortby = $1; |
53 |
| - } else { |
54 |
| - $sortby = shift @ARGV; |
55 |
| - if (! defined $sortby) { |
56 |
| - die "'--sort-by' requires an argument"; |
57 |
| - } |
58 |
| - } |
59 |
| - next; |
60 |
| - } |
61 |
| - if ($arg eq "--subsection") { |
62 |
| - shift @ARGV; |
63 |
| - $subsection = $ARGV[0]; |
64 |
| - shift @ARGV; |
65 |
| - if (! $subsection) { |
66 |
| - die "empty subsection"; |
67 |
| - } |
68 |
| - next; |
69 |
| - } |
70 |
| - if ($arg eq "--reponame") { |
71 |
| - shift @ARGV; |
72 |
| - $reponame = $ARGV[0]; |
73 |
| - shift @ARGV; |
74 |
| - if (! $reponame) { |
75 |
| - die "empty reponame"; |
76 |
| - } |
77 |
| - next; |
78 |
| - } |
79 | 68 | last if -f $arg or $arg eq "--";
|
80 | 69 | if (! -d $arg) {
|
81 | 70 | my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
|
@@ -225,7 +214,8 @@ sub print_sorted_results {
|
225 | 214 | my ($sortby) = @_;
|
226 | 215 |
|
227 | 216 | if ($sortby ne "regression") {
|
228 |
| - die "only 'regression' is supported as '--sort-by' argument"; |
| 217 | + print "Only 'regression' is supported as '--sort-by' argument\n"; |
| 218 | + usage(); |
229 | 219 | }
|
230 | 220 |
|
231 | 221 | my @evolutions;
|
|
0 commit comments