Merge pull request #311 from hlhr/master

List command without parameter lists all installed packages with versions
This commit is contained in:
Trevor Brown 2018-04-18 11:16:52 -04:00 committed by GitHub
commit 7774de9137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 5 deletions

View File

@ -1,9 +1,28 @@
list_command() {
local plugin_name=$1
check_if_plugin_exists "$plugin_name"
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 "$plugin_name")
versions=$(list_installed_versions "$1")
if [ -n "${versions}" ]; then
for version in $versions; do
@ -13,4 +32,4 @@ list_command() {
display_error 'No versions installed'
exit 1
fi
}
}

View File

@ -14,13 +14,21 @@ teardown() {
clean_asdf_dir
}
@test "list_command should output error when plugin is not installed" {
@test "list_command should list plugins with installed versions" {
run install_command dummy 1.0
run install_command dummy 1.1
run list_command
[ "$(echo -e "dummy\n1.0\n1.1")" == "$output" ]
[ "$status" -eq 0 ]
}
@test "list_command with plugin should output error when plugin is not installed" {
run list_command dummy
[ "No versions installed" == "$output" ]
[ "$status" -eq 1 ]
}
@test "list_command should list installed versions" {
@test "list_command with plugin should list installed versions" {
run install_command dummy 1.0
run install_command dummy 1.1
run list_command dummy