asdf/lib/commands/list.sh
Trevor Brown c1ce9de4d4
Merge pull request #331 from brennanfee/fix-330-asdf-list
Fix for #330 - "asdf list" spacing
2018-06-16 15:30:35 -04:00

36 lines
798 B
Bash

list_command() {
local plugin_name=$1
if [ -z "$plugin_name" ]; then
local plugins_path
plugins_path=$(get_plugin_path)
if ls "$plugins_path" &> /dev/null; then
for plugin_path in "$plugins_path"/* ; do
plugin_name=$(basename "$plugin_path")
echo "$plugin_name"
display_installed_versions "$plugin_name"
done
else
printf "%s\\n" 'Oohes nooes ~! No plugins installed'
fi
else
check_if_plugin_exists "$plugin_name"
display_installed_versions "$plugin_name"
fi
}
display_installed_versions() {
local versions
versions=$(list_installed_versions "$1")
if [ -n "${versions}" ]; then
for version in $versions; do
echo " $version"
done
else
display_error 'No versions installed'
exit 1
fi
}