trove/tools/with_venv.sh
Zhenguo Niu d4b324573f Enclose command args in with_venv.sh
It will support argument with blanks.

Change-Id: I83313290a964bf10fe46570f43cf213ceab8a326
Fixes: bug #1220937
2013-09-09 15:02:40 +08:00

31 lines
478 B
Bash
Executable File

#!/bin/bash
set -e
me=${0##*/}
dir="$(dirname $0)"
function print_usage() {
cat >&2 <<EOS
Run commands in a default (or specific) virtualenv
Usage: $me [-E venv] commands
Options:
-h prints out this message
-E venv use this virtualenv (default: ${venv})
EOS
}
venv="${dir}/../.venv"
while getopts ":hE:" opt; do
case "$opt" in
h|\?) print_usage; exit 1 ;;
E) venv=$OPTARG ;;
esac
done
shift $((OPTIND-1))
source "${venv}/bin/activate" && "$@"