Преглед на файлове

Display error if `pyenv activate` was invoked as a command

check-usage-before-uninstall
Yamashita Yuu преди 10 години
родител
ревизия
503a51564e
променени са 4 файла, в които са добавени 59 реда и са изтрити 0 реда
  1. +26
    -0
      bin/pyenv-activate
  2. +21
    -0
      bin/pyenv-deactivate
  3. +6
    -0
      test/activate.bats
  4. +6
    -0
      test/deactivate.bats

+ 26
- 0
bin/pyenv-activate Целия файл

@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# Summary: Activate virtual environment
#
# Usage: pyenv activate <virtualenv>
# pyenv activate --unset
#
# Activate a Python virtualenv environment in current shell.
# This acts almost as same as `pyenv shell`, but this invokes the `activate`
# script in your shell.
#
# <virtualenv> should be a string matching a Python version known to pyenv.
set -e
[ -n "$PYENV_DEBUG" ] && set -x
{ printf "\x1B[31;1m"
echo
echo "Failed to activate virtualenv."
echo
echo "Perhaps pyenv-virtualenv has not been loaded into your shell properly."
echo "Please restart current shell and try again."
echo
printf "\x1B[0m"
} 1>&2
exit 1

+ 21
- 0
bin/pyenv-deactivate Целия файл

@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# Summary: Deactivate virtual environment
#
# Usage: pyenv deactivate
#
# Deactivate a Python virtual environment.
set -e
[ -n "$PYENV_DEBUG" ] && set -x
{ printf "\x1B[31;1m"
echo
echo "Failed to deactivate virtualenv."
echo
echo "Perhaps pyenv-virtualenv has not been loaded into your shell properly."
echo "Please restart current shell and try again."
echo
printf "\x1B[0m"
} 1>&2
exit 1

+ 6
- 0
test/activate.bats Целия файл

@ -85,3 +85,9 @@ EOS
pyenv-virtualenv: cannot activate multiple versions at once: venv venv27
EOS
}
@test "should fail if activate is invoked as a command" {
run pyenv-activate
assert_failure
}

+ 6
- 0
test/deactivate.bats Целия файл

@ -25,3 +25,9 @@ functions -q deactivate; and deactivate
pyenv shell --unset
EOS
}
@test "should fail if deactivate is invoked as a command" {
run pyenv-deactivate
assert_failure
}

Зареждане…
Отказ
Запис