Display error if pyenv activate was invoked as a command

This commit is contained in:
Yamashita Yuu
2014-01-25 19:14:58 +09:00
parent 1db565b67c
commit 503a51564e
4 changed files with 59 additions and 0 deletions

26
bin/pyenv-activate Executable file
View File

@@ -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
bin/pyenv-deactivate Executable file
View File

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

View File

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

View File

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