]> code.ossystems Code Review - openembedded-core.git/commitdiff
build-perf-test-wrapper.sh: parse args with getopts
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 19 Aug 2016 10:48:58 +0000 (13:48 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 25 Aug 2016 22:00:08 +0000 (23:00 +0100)
Use getopts for parsing the command line. This changes the usage so that
if a commit (to-be-tested) is defined it must be given by using '-c',
instead of a positional argument.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/contrib/build-perf-test-wrapper.sh

index e8e8021d58ddca1c43a835d9b97bdf1f1aa35087..8eb4fdbc6ca7fbf0055af6e4a91600149bca56e3 100755 (executable)
 
 script=`basename $0`
 usage () {
-    echo "Usage: $script [COMMITISH]"
+cat << EOF
+Usage: $script [-h] [-c COMMITISH] [-C GIT_REPO]
+
+Optional arguments:
+  -h                show this help and exit.
+  -c COMMITISH      test (checkout) this commit
+EOF
 }
 
-if [ $# -gt 1 ]; then
-    usage
-    exit 1
-fi
-commitish=$1
 
-echo "Running on `uname -n`"
+# Parse command line arguments
+commitish=""
+while getopts "hc:" opt; do
+    case $opt in
+        h)  usage
+            exit 0
+            ;;
+        c)  commitish=$OPTARG
+            ;;
+        *)  usage
+            exit 1
+            ;;
+    esac
+done
+
 
+echo "Running on `uname -n`"
 if ! git_topdir=$(git rev-parse --show-toplevel); then
         echo "The current working dir doesn't seem to be a git clone. Please cd there before running `basename $0`"
         exit 1