From 1c2c8dd66e9e28ee8e81d4bafe15684e644a15c1 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Tue, 28 Jul 2026 11:51:08 +0300 Subject: [PATCH] Add and use `pyenv install --list --bare` --- .../pyenv-binary/libexec/pyenv-binary-package | 3 +-- plugins/python-build/bin/pyenv-install | 22 +++++++++++++++---- plugins/python-build/test/pyenv.bats | 17 ++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/plugins/pyenv-binary/libexec/pyenv-binary-package b/plugins/pyenv-binary/libexec/pyenv-binary-package index 678d08a5..42294ed1 100755 --- a/plugins/pyenv-binary/libexec/pyenv-binary-package +++ b/plugins/pyenv-binary/libexec/pyenv-binary-package @@ -24,8 +24,7 @@ set -e # Provide pyenv completions if [ "$1" = "--complete" ]; then echo --archive-base-url - pyenv-install --list | sed '1d; s/^ //' - exit + exec pyenv-install --list --bare fi spec="" diff --git a/plugins/python-build/bin/pyenv-install b/plugins/python-build/bin/pyenv-install index 4d0220ed..4a5e71c1 100755 --- a/plugins/python-build/bin/pyenv-install +++ b/plugins/python-build/bin/pyenv-install @@ -4,7 +4,7 @@ # # Usage: pyenv install [-f] [-kvp] [:]... # pyenv install [-f] [-kvp] [:] -# pyenv install -l|--list +# pyenv install -l|--list [--bare] # pyenv install --version # # -l/--list List all available versions @@ -45,6 +45,7 @@ shopt -u nullglob # Provide pyenv completions if [ "$1" = "--complete" ]; then + echo --bare echo --list echo --force echo --skip-existing @@ -79,6 +80,8 @@ unset KEEP unset VERBOSE unset HAS_PATCH unset DEBUG +unset BARE +unset LIST [ -n "$PYENV_DEBUG" ] && VERBOSE="-v" @@ -88,10 +91,11 @@ for option in "${OPTIONS[@]}"; do "h" | "help" ) usage 0 ;; + "bare" ) + BARE=1 + ;; "l" | "list" ) - echo "Available versions:" - definitions | indent - exit + LIST=1 ;; "f" | "force" ) FORCE=true @@ -120,6 +124,16 @@ for option in "${OPTIONS[@]}"; do esac done +if [[ -n $LIST ]]; then + if [[ -n $BARE ]]; then + definitions + else + echo "Available versions:" + definitions | indent + fi + exit +fi + unset VERSION_NAME # The first argument contains the definition to install. If the diff --git a/plugins/python-build/test/pyenv.bats b/plugins/python-build/test/pyenv.bats index 8d4ec144..12d7d2de 100644 --- a/plugins/python-build/test/pyenv.bats +++ b/plugins/python-build/test/pyenv.bats @@ -160,6 +160,22 @@ OUT unstub python-build } +@test "list available versions with --bare" { + stub_python_build_lib + stub_python_build "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'" + + run pyenv-install --list --bare + assert_success + assert_output <