Add and use pyenv install --list --bare

This commit is contained in:
Ivan Pozdeev 2026-07-28 11:51:08 +03:00
parent 41bb8f6106
commit 1c2c8dd66e
3 changed files with 36 additions and 6 deletions

View file

@ -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=""

View file

@ -4,7 +4,7 @@
#
# Usage: pyenv install [-f] [-kvp] <version>[:<alias>]...
# pyenv install [-f] [-kvp] <definition-file>[:<alias>]
# 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

View file

@ -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 <<OUT
2.6.9
2.7.9-rc1
2.7.9-rc2
3.4.2
OUT
unstub python-build
}
@test "upgrade instructions given for a nonexistent version" {
stub brew false
stub_python_build_lib
@ -265,6 +281,7 @@ OUT
run pyenv-install --complete
assert_success
assert_output <<OUT
--bare
--list
--force
--skip-existing