From 7f47b3121fddb62d3a20de96b79a63bc7ea5fd79 Mon Sep 17 00:00:00 2001 From: Jesse Wattenbarger Date: Fri, 8 Sep 2023 08:24:03 -0400 Subject: [PATCH] Add --bare option to `pyenv version` It just points at pyenv version-name. This adds consistency with the behavior of `pyenv versions --bare` --- libexec/pyenv-version | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libexec/pyenv-version b/libexec/pyenv-version index 33de9325..79f0275f 100755 --- a/libexec/pyenv-version +++ b/libexec/pyenv-version @@ -1,9 +1,10 @@ #!/usr/bin/env bash # Summary: Show the current Python version(s) and its origin +# Usage: pyenv version [--bare] # # Shows the currently selected Python version(s) and how it was -# selected. To obtain only the version string, use `pyenv -# version-name'. +# selected. To obtain only the version string, use `pyenv version +# --bare` or `pyenv version-name'. set -e [ -n "$PYENV_DEBUG" ] && set -x @@ -13,8 +14,25 @@ OLDIFS="$IFS" IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$? IFS="$OLDIFS" +unset bare +for arg; do + case "$arg" in + --complete ) + echo --bare + exit ;; + --bare ) bare=1 ;; + * ) + pyenv-help --usage version >&2 + exit 1 + ;; + esac +done for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do - echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))" + if [[ -n $bare ]]; then + echo "$PYENV_VERSION_NAME" + else + echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))" + fi done exit $exitcode