asdf/lib/commands/command-list-all.bash

28 lines
532 B
Bash
Raw Normal View History

# -*- sh -*-
2015-05-17 00:46:56 -07:00
list_all_command() {
local plugin_name=$1
local query=$2
2017-09-04 10:04:56 -07:00
local plugin_path
plugin_path=$(get_plugin_path "$plugin_name")
check_if_plugin_exists "$plugin_name"
2015-05-21 22:17:44 -07:00
2017-09-04 10:04:56 -07:00
local versions
versions=$(bash "${plugin_path}/bin/list-all")
2015-05-07 22:58:07 -07:00
if [[ $query ]]; then
2019-11-29 09:15:38 -07:00
versions=$(echo "$versions" |
tr ' ' '\n' |
2020-01-29 06:04:39 -07:00
grep -E "^\\s*$query" |
2019-11-29 09:15:38 -07:00
tr '\n' ' ')
fi
2019-11-29 09:15:38 -07:00
IFS=' ' read -r -a versions_list <<<"$versions"
2015-05-07 22:58:07 -07:00
2019-11-29 09:15:38 -07:00
for version in "${versions_list[@]}"; do
2015-05-17 00:46:56 -07:00
echo "${version}"
done
}
list_all_command "$@"