From: Nathan Cutler Date: Fri, 23 Mar 2018 10:34:04 +0000 (+0100) Subject: tools: setup-virtualenv.sh: add usage function and --help option X-Git-Tag: v13.1.0~507^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a93474f76deeced7dbead8e077da45930f0f733;p=ceph.git tools: setup-virtualenv.sh: add usage function and --help option Signed-off-by: Nathan Cutler --- diff --git a/src/tools/setup-virtualenv.sh b/src/tools/setup-virtualenv.sh index 9d888ce8cb0c9..25373d81447b0 100755 --- a/src/tools/setup-virtualenv.sh +++ b/src/tools/setup-virtualenv.sh @@ -16,13 +16,30 @@ # 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 ;;