Refactor "no version set" message to utilities

This commit is contained in:
AJ Foster 2018-02-25 17:42:33 -05:00
parent 9733daafd4
commit eb5e5b780c
5 changed files with 9 additions and 4 deletions

View File

@ -12,7 +12,7 @@ check_if_plugin_exists "$plugin_name"
full_version=$(get_preset_version_for "$plugin_name")
if [ "$full_version" == "" ]; then
echo "No version set for ${plugin_name}: please run \`asdf <global|local> ${plugin_name} <version>\`"
display_no_version_set "$plugin_name"
exit -1
fi

View File

@ -16,7 +16,7 @@ plugin_current_command() {
check_for_deprecated_plugin "$plugin_name"
if [ -z "$version" ]; then
printf "%s\\n" "No version set for $plugin_name: please run \`asdf <global|local> ${plugin_name} <version>\`"
printf "%s\\n" "$(display_no_version_set "$plugin_name")"
exit 1
else
printf "%-8s%s\\n" "$version" "(set by $version_file_path)"

View File

@ -14,7 +14,7 @@ current_version() {
check_for_deprecated_plugin "$plugin_name"
if [ -z "$version" ]; then
echo "No version set for $plugin_name: please run \`asdf <global|local> ${plugin_name} <version>\`"
display_no_version_set "$plugin_name"
exit 1
else
echo "$version"

View File

@ -160,6 +160,11 @@ find_version() {
fi
}
display_no_version_set() {
local plugin_name=$1
echo "No version set for ${plugin_name}; please run \`asdf <global | local> ${plugin_name} <version>\`"
}
get_version_from_env () {
local plugin_name=$1
local upcase_name

View File

@ -75,7 +75,7 @@ teardown() {
echo 'foobar 1.0.0' >> $PROJECT_DIR/.tool-versions
run current_command
expected="baz No version set for baz: please run \`asdf <global|local> baz <version>\`
expected="baz No version set for baz; please run \`asdf <global | local> baz <version>\`
dummy 1.1.0 (set by $PROJECT_DIR/.tool-versions)
foobar 1.0.0 (set by $PROJECT_DIR/.tool-versions)"