]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: setup-virtualenv.sh: add usage function and --help option
authorNathan Cutler <ncutler@suse.com>
Fri, 23 Mar 2018 10:34:04 +0000 (11:34 +0100)
committerNathan Cutler <ncutler@suse.com>
Fri, 23 Mar 2018 10:34:04 +0000 (11:34 +0100)
Signed-off-by: Nathan Cutler <ncutler@suse.com>
src/tools/setup-virtualenv.sh

index 9d888ce8cb0c908a20c1ad6029808006e1afb561..25373d81447b0ffca0f0899911afc8e7f8d10928 100755 (executable)
 #
 
 SCRIPTNAME="$(basename $0)"
+PYTHON_BINARY="python2.7"
+
+function usage {
+    echo
+    echo "$SCRIPTNAME - automate setup of Python virtual environment"
+    echo "    (for use in building Ceph)"
+    echo
+    echo "Usage:"
+    echo "    $SCRIPTNAME [--python=PYTHON_BINARY] TARGET_DIRECTORY"
+    echo
+    echo "    PYTHON_BINARY defaults to \"$PYTHON_BINARY\""
+    echo "    TARGET_DIRECTORY will be created if it doesn't exist,"
+    echo "        and completely destroyed and re-created if it does!"
+    echo
+    exit 1
+}
 
-TEMP=$(getopt --options "" --long "python:" --name "$SCRIPTNAME" -- "$@")
-if [ $? != 0 ] ; then echo "Failed to parse options...exiting" >&2 ; exit 1 ; fi
+TEMP=$(getopt --options "h" --long "help,python:" --name "$SCRIPTNAME" -- "$@")
+test $? != 0 && usage
 eval set -- "$TEMP"
-PYTHON_BINARY="python2.7"
+
 while true ; do
     case "$1" in
+        -h|--help) usage ;;  # does not return
         --python) PYTHON_BINARY="$2" ; shift ; shift ;;
         --) shift ; break ;;
         *) echo "Internal error" ; exit 1 ;;