mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Refactor "no version set" message to utilities
This commit is contained in:
parent
9733daafd4
commit
eb5e5b780c
@ -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
|
||||
|
||||
|
@ -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)"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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)"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user