Skip to content

Commit a0486a5

Browse files
committed
Add one more option -t | --top
1 parent a217f5d commit a0486a5

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

libs/show_results_table.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77

88
rsort($results);
99

10-
if (preg_match("/output\/(\S+)/", @$results[0], $match)) {
10+
$index = 0;
11+
if (!empty($argv[1]) && $argv[1]<count($results)) {
12+
$index = $argv[1];
13+
}
14+
15+
if (preg_match("/output\/(\S+)/", @$results[$index], $match)) {
1116
echo "Results: ".@$match[1].PHP_EOL;
1217
}
1318

14-
$pr = parse_results(@$results[0].'/results.log');
19+
$pr = parse_results(@$results[$index].'/results.log');
1520

1621
echo build_table($pr);

results.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ function showHelp()
1212
Usage: bash results.sh [-l] [-t 1] [-d 2]
1313
1414
Optional Arguments:
15-
-l, --list Show all results in order
16-
1715
-d [index], --delete [index] Delete by index id (use --list)
1816
-dall, --deleteall Delete all results
1917
-h, --help Show this help message and exit
18+
-l, --list Show all results in order
19+
-t [index], --top [index] Specify a result by index (use --list)
2020
2121
HEREDOC
2222
}
@@ -32,7 +32,7 @@ IFS=$oldIFS
3232

3333

3434
results=(`ls ./output/`)
35-
35+
index=0
3636
for option in "${params[@]}"
3737
do
3838
case "$option" in
@@ -61,6 +61,13 @@ do
6161
done
6262
exit 1
6363
;;
64+
-t*|--top*)
65+
top=${option//--top /}
66+
top=${option//-t /}
67+
if [ ${#top} -ge 0 ]; then
68+
index="$top"
69+
fi
70+
;;
6471
-h|--help)
6572
showHelp;
6673
exit 1
@@ -73,4 +80,4 @@ do
7380
esac
7481
done
7582

76-
php ./libs/show_results_table.php
83+
php ./libs/show_results_table.php $index

0 commit comments

Comments
 (0)