asdf/lib/commands/command-latest

20 lines
473 B
Plaintext
Raw Normal View History

# -*- sh -*-
latest_command() {
DEFAULT_QUERY="[0-9]"
local plugin_name=$1
local query=$2
[[ -z $query ]] && query="$DEFAULT_QUERY"
2019-11-22 11:37:53 -07:00
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest)
2019-11-29 09:15:38 -07:00
asdf list-all "$plugin_name" "$query" |
2020-01-29 06:04:39 -07:00
grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" |
2019-11-29 09:15:38 -07:00
sed 's/^\s\+//' |
sort --version-sort |
tail -1
}
latest_command "$@"