2019-11-27 01:24:29 -07:00
|
|
|
# -*- sh -*-
|
|
|
|
|
2015-05-17 00:46:56 -07:00
|
|
|
list_command() {
|
2015-05-26 23:46:17 -07:00
|
|
|
local plugin_name=$1
|
2021-07-06 04:17:00 -07:00
|
|
|
local query=$2
|
2015-05-07 22:58:07 -07:00
|
|
|
|
2018-04-16 15:37:22 -07:00
|
|
|
if [ -z "$plugin_name" ]; then
|
|
|
|
local plugins_path
|
|
|
|
plugins_path=$(get_plugin_path)
|
|
|
|
|
2021-12-29 10:10:39 -07:00
|
|
|
if find "$plugins_path" -mindepth 1 -type d &>/dev/null; then
|
2022-05-12 04:48:54 -07:00
|
|
|
for plugin_path in "$plugins_path"/*/; do
|
2018-04-16 15:37:22 -07:00
|
|
|
plugin_name=$(basename "$plugin_path")
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "%s\n" "$plugin_name"
|
2021-07-06 04:17:00 -07:00
|
|
|
display_installed_versions "$plugin_name" "$query"
|
2018-04-16 15:37:22 -07:00
|
|
|
done
|
|
|
|
else
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "%s\n" 'No plugins installed'
|
2018-04-16 15:37:22 -07:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
check_if_plugin_exists "$plugin_name"
|
2021-07-06 04:17:00 -07:00
|
|
|
display_installed_versions "$plugin_name" "$query"
|
2018-04-16 15:37:22 -07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
display_installed_versions() {
|
2021-07-06 04:17:00 -07:00
|
|
|
local plugin_name=$1
|
|
|
|
local query=$2
|
2017-09-04 10:04:56 -07:00
|
|
|
local versions
|
2022-06-21 05:54:02 -07:00
|
|
|
local current_version
|
|
|
|
local flag
|
|
|
|
|
2021-07-06 04:17:00 -07:00
|
|
|
versions=$(list_installed_versions "$plugin_name")
|
|
|
|
|
|
|
|
if [[ $query ]]; then
|
|
|
|
versions=$(printf "%s\n" "$versions" | grep -E "^\s*$query")
|
|
|
|
|
|
|
|
if [ -z "${versions}" ]; then
|
|
|
|
display_error "No compatible versions installed ($plugin_name $query)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-05-11 09:20:28 -07:00
|
|
|
|
2016-12-10 12:54:22 -07:00
|
|
|
if [ -n "${versions}" ]; then
|
2022-12-27 06:33:59 -07:00
|
|
|
current_version=$(cut -d '|' -f 1 <<<"$(find_versions "$plugin_name" "$PWD")")
|
2022-06-21 05:54:02 -07:00
|
|
|
|
2016-12-10 12:54:22 -07:00
|
|
|
for version in $versions; do
|
2022-06-21 05:54:02 -07:00
|
|
|
flag=" "
|
|
|
|
if [[ "$version" == "$current_version" ]]; then
|
|
|
|
flag=" *"
|
|
|
|
fi
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "%s%s\n" "$flag" "$version"
|
2015-05-17 00:46:56 -07:00
|
|
|
done
|
|
|
|
else
|
2020-05-18 09:18:27 -07:00
|
|
|
display_error ' No versions installed'
|
2015-05-17 00:46:56 -07:00
|
|
|
fi
|
2018-06-16 12:04:38 -07:00
|
|
|
}
|
2019-11-27 01:24:29 -07:00
|
|
|
|
|
|
|
list_command "$@"
|