Skip to content

Commit 90c1073

Browse files
Add a usage string when run without options
1 parent 29839a0 commit 90c1073

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

third_party/cli_bench/cli_bench.pl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
'ignore=i' => \$ignore,
2525
);
2626

27-
my $cmd = join(" ", @ARGV);
27+
28+
my $cmd = trim(join(" ", @ARGV));
29+
30+
if (!$cmd) {
31+
die(usage());
32+
}
2833

2934
$| = 0; # Disable output buffering
3035

@@ -49,6 +54,7 @@
4954

5055
# Remove the top and bottom 10%
5156
my $outlier = $num / 10;
57+
@res = sort(@res);
5258
@res = splice(@res, $outlier, $num - $outlier * 2);
5359

5460
my $avg = int(average(@res));
@@ -173,5 +179,8 @@ BEGIN
173179
}
174180
}
175181

176-
# vim: tabstop=4 shiftwidth=4 autoindent softtabstop=4
182+
sub usage {
183+
return "Usage: $0 [--num 50] 'cat /tmp/simple.diff | diff-so-fancy'\n";
184+
}
177185

186+
# vim: tabstop=4 shiftwidth=4 autoindent softtabstop=4

0 commit comments

Comments
 (0)