2019-11-27 01:24:29 -07:00
|
|
|
# -*- sh -*-
|
|
|
|
|
2019-11-22 11:37:52 -07:00
|
|
|
latest_command() {
|
|
|
|
DEFAULT_QUERY="[0-9]"
|
|
|
|
|
|
|
|
local plugin_name=$1
|
|
|
|
local query=$2
|
2021-07-06 19:51:19 -07:00
|
|
|
local plugin_path
|
2019-11-22 11:37:52 -07:00
|
|
|
|
|
|
|
[[ -z $query ]] && query="$DEFAULT_QUERY"
|
|
|
|
|
2021-07-06 19:51:19 -07:00
|
|
|
plugin_path=$(get_plugin_path "$plugin_name")
|
|
|
|
check_if_plugin_exists "$plugin_name"
|
|
|
|
|
2021-07-06 04:17:00 -07:00
|
|
|
local versions
|
2021-07-06 19:51:19 -07:00
|
|
|
|
|
|
|
if [ -f "${plugin_path}/bin/latest-stable" ]; then
|
2021-07-29 15:44:14 -07:00
|
|
|
versions=$("${plugin_path}"/bin/latest-stable "$query")
|
2021-07-06 19:51:19 -07:00
|
|
|
if [ -z "${versions}" ]; then
|
|
|
|
# this branch requires this print to mimic the error from the list-all branch
|
|
|
|
printf "No compatible versions available (%s %s)\n" "$plugin_name" "$query" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest)
|
|
|
|
versions=$(asdf list-all "$plugin_name" "$query" |
|
|
|
|
grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" |
|
2021-09-13 06:16:13 -07:00
|
|
|
sed 's/^[[:space:]]\+//' |
|
2021-07-06 19:51:19 -07:00
|
|
|
tail -1)
|
|
|
|
if [ -z "${versions}" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-07-06 04:17:00 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
printf "%s\n" "$versions"
|
2019-11-22 11:37:52 -07:00
|
|
|
}
|
2019-11-27 01:24:29 -07:00
|
|
|
|
|
|
|
latest_command "$@"
|