2019-11-27 01:24:29 -07:00
|
|
|
# -*- sh -*-
|
|
|
|
|
|
|
|
# Output from this command must be executable shell code
|
|
|
|
shell_command() {
|
|
|
|
local asdf_shell="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
if [ "$#" -lt "2" ]; then
|
|
|
|
echo "Usage: asdf shell <name> {<version>|--unset}" >&2
|
|
|
|
echo 'false'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
local plugin=$1
|
|
|
|
local version=$2
|
|
|
|
|
|
|
|
local upcase_name
|
|
|
|
upcase_name=$(echo "$plugin" | tr '[:lower:]-' '[:upper:]_')
|
|
|
|
local version_env_var="ASDF_${upcase_name}_VERSION"
|
|
|
|
|
|
|
|
if [ "$version" = "--unset" ]; then
|
2020-01-25 13:35:36 -07:00
|
|
|
case "$asdf_shell" in
|
2020-06-29 16:16:35 -07:00
|
|
|
fish)
|
|
|
|
echo "set -e $version_env_var"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unset $version_env_var"
|
|
|
|
;;
|
2020-01-25 13:35:36 -07:00
|
|
|
esac
|
2019-11-27 01:24:29 -07:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if ! (check_if_version_exists "$plugin" "$version"); then
|
2020-08-28 16:09:22 -07:00
|
|
|
version_not_installed_text "$plugin" "$version" 1>&2
|
2019-11-27 01:24:29 -07:00
|
|
|
echo 'false'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$asdf_shell" in
|
2020-06-29 16:16:35 -07:00
|
|
|
fish)
|
|
|
|
echo "set -gx $version_env_var \"$version\""
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "export $version_env_var=\"$version\""
|
|
|
|
;;
|
2019-11-27 01:24:29 -07:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
shell_command "$@"
|