diff --git a/bin/configure b/bin/configure index 31422e3..e194d8f 100755 --- a/bin/configure +++ b/bin/configure @@ -4,16 +4,14 @@ set -euC _venv() { _py_version=${1:-3.12.0} - if command -v pyenv >/dev/null 2>&1; then - pyenv install $_py_version - pyenv shell $_py_version - if [ -d .venv ]; then - rm -rf .venv - fi - python -m venv ".venv" - else - echo "Please install pyenv" + pyenv install $_py_version + pyenv shell $_py_version + + if [ -d .venv ]; then + rm -rf .venv fi + + python -m venv ".venv" } VENV_match=venv @@ -32,7 +30,7 @@ _freeze() { if [ -d .venv ]; then source .venv/bin/activate mv requirements.txt requirements.txt.bak - pip freeze >requirements.txt + pip freeze > requirements.txt else echo "Please run 'bin/configure init' first" fi @@ -48,28 +46,31 @@ _help() { } _check_cmds() { - if ! command -v pyenv >/dev/null 2>&1; then - echo "Please install pyenv" - _fail=true - fi + if ! command -v pyenv >/dev/null; then + echo "Please install pyenv" + _fail=true + fi } _main() { - _fail=false - _check_cmds + export _fail=false + _check_cmds - if $_fail; then - exit 1 - fi + if $_fail; then + exit 1 + fi _cmd="${1:-help}" + if ! [ -z "$_cmd" ]; then + shift + fi case "$_cmd" in --*) ;; help | -h) _help ;; - "$VENV_match") _venv "${2:-}" ;; + "$VENV_match") _venv "$@" ;; "$INIT_match") - _venv "${2:-}" + _venv "$@" _init ;; "$FREEZE_match") _freeze ;;