mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Merge pull request #311 from hlhr/master
List command without parameter lists all installed packages with versions
This commit is contained in:
commit
7774de9137
@ -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
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user