refactor: improve bin/configure

This commit is contained in:
Mark Bailey 2024-10-26 19:52:09 -04:00
parent 6a5500797d
commit 9972351903

17
bin/configure vendored
View File

@ -4,16 +4,14 @@ set -euC
_venv() { _venv() {
_py_version=${1:-3.12.0} _py_version=${1:-3.12.0}
if command -v pyenv >/dev/null 2>&1; then
pyenv install $_py_version pyenv install $_py_version
pyenv shell $_py_version pyenv shell $_py_version
if [ -d .venv ]; then if [ -d .venv ]; then
rm -rf .venv rm -rf .venv
fi fi
python -m venv ".venv" python -m venv ".venv"
else
echo "Please install pyenv"
fi
} }
VENV_match=venv VENV_match=venv
@ -48,14 +46,14 @@ _help() {
} }
_check_cmds() { _check_cmds() {
if ! command -v pyenv >/dev/null 2>&1; then if ! command -v pyenv >/dev/null; then
echo "Please install pyenv" echo "Please install pyenv"
_fail=true _fail=true
fi fi
} }
_main() { _main() {
_fail=false export _fail=false
_check_cmds _check_cmds
if $_fail; then if $_fail; then
@ -63,13 +61,16 @@ _main() {
fi fi
_cmd="${1:-help}" _cmd="${1:-help}"
if ! [ -z "$_cmd" ]; then
shift
fi
case "$_cmd" in case "$_cmd" in
--*) ;; --*) ;;
help | -h) _help ;; help | -h) _help ;;
"$VENV_match") _venv "${2:-}" ;; "$VENV_match") _venv "$@" ;;
"$INIT_match") "$INIT_match")
_venv "${2:-}" _venv "$@"
_init _init
;; ;;
"$FREEZE_match") _freeze ;; "$FREEZE_match") _freeze ;;