From 2a93474f76deeced7dbead8e077da45930f0f733 Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Fri, 23 Mar 2018 11:34:04 +0100 Subject: [PATCH] tools: setup-virtualenv.sh: add usage function and --help option Signed-off-by: Nathan Cutler --- src/tools/setup-virtualenv.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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 ;; -- 2.39.5