Skip to content

Commit

Permalink
Add more options
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaghubi committed Aug 11, 2023
1 parent 91a9ae7 commit a217f5d
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ if [ ! `which php` ]; then
exit 1;
fi

function showHelp()
{
cat << HEREDOC
Usage: bash results.sh [-l] [-t 1] [-d 2]
Optional Arguments:
-l, --list Show all results in order
-d [index], --delete [index] Delete by index id (use --list)
-dall, --deleteall Delete all results
-h, --help Show this help message and exit
HEREDOC
}

oldIFS="$IFS"
paramsin="${@%/}"
IFS='()'
Expand All @@ -20,18 +36,39 @@ results=(`ls ./output/`)
for option in "${params[@]}"
do
case "$option" in
-dall|--deleteall)
rm -rf ./output/*
;;
-d*|--delete*)
delete=${option//--delete /}
delete=${option//-d /}
if [ ${#delete} -ge 0 ]; then
for i in "${!results[@]}"; do
if [ $delete -eq $i ]; then
echo "Delete ./output/${results[$i]}"
rm -rf "./output/${results[$i]}"
exit 1
fi
done
echo "Index $delete not found!"
fi
exit 1
;;
-l|--list)
echo "List of results: "
for i in "${!results[@]}"; do
echo "$i) ${results[$i]}"
done
exit 1
;;
-h|--help)
showHelp;
exit 1
;;
""|" ")
;;
*)
echo "\"${option}\" not available"
exit 1
;;
esac
done
Expand Down

0 comments on commit a217f5d

Please sign in to comment.