Skip to content

Commit

Permalink
feat: more opts for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Dec 6, 2023
1 parent b71bf11 commit e95a8e0
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions scripts/run-pyo3-greptime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ setup_conda_env() {
get_optional_args(){
# if not set by --path path-of-greptime-executable
# default to search local folder for greptime executable
ARGS=$(getopt -o "p:" -l "path:" -- "$@")

ARGS=$(getopt -o "p:y::e:" -l "path:,yes::,env:" -- "$@")
# assign ARGS to positional parameters $1, $2, etc...
eval set -- "$ARGS"
unset ARGS
Expand All @@ -58,16 +57,27 @@ get_optional_args(){
# parse for path
while true; do
case "$1" in
-p)
-p|--path)
shift
exec_path="$1"
shift
;;
-y|--yes)
shift
export YESMAN=1
shift
;;
-e|--env)
shift
export USE_ENV="$1"
shift
;;
--)
shift
break
;;
*)
echo "Error parsing arguments: $1"
break
;;
esac
Expand All @@ -87,8 +97,8 @@ execute_greptime() {

main() {
get_optional_args $@
echo GREPTIME_EXEC_PATH: $GREPTIME_EXEC_PATH
echo REST_OF_ARGS: $REST_OF_ARGS
echo Path of greptime executable: $GREPTIME_EXEC_PATH
echo Args passed to greptime executable: $REST_OF_ARGS
local req_py_version
req_py_version=$(get_python_version)
readonly req_py_version
Expand All @@ -98,35 +108,45 @@ main() {
$GREPTIME_EXEC_PATH $REST_OF_ARGS
else
echo "The 'greptime' binary is not valid or encountered an error."
$GREPTIME_EXEC_PATH --version
exit 1
fi
return
fi

echo "The required version of Python shared library is $req_py_version"

echo "Now this script will try to install or find correct Python Version"
echo "Do you want to continue? (yes/no): "
read -r yn
# if YESMAN exist, assign it to yn, else read from stdin
if [[ -z "$YESMAN" ]]; then
echo "Now this script will try to install or find correct Python Version"
echo "Do you want to continue? (yes/no): "
read -r yn
else
yn="y"
fi
case $yn in
[Yy]* ) ;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac

echo "choose your perfered way to install python"
echo "1. virtualenv"
echo "2. conda"
echo "Input your choice [1/2]: "
read -r option
# if USE_ENV exist, assign it to option
# else read from stdin
if [[ -z "$USE_ENV" ]]; then
echo "Do you want to use virtualenv or conda? (virtualenv(1)/conda(2)): "
read -r option
else
option="$USE_ENV"
fi
case $option in
1)
setup_virtualenv "$req_py_version"
;;
2)
setup_conda_env "$req_py_version"
;;
*) echo "Please input 1 or 2"; exit 1;;
*)
echo "Please input 1 or 2"; exit 1
;;
esac

execute_greptime $REST_OF_ARGS
Expand Down

0 comments on commit e95a8e0

Please sign in to comment.