2019-11-27 01:24:29 -07:00
|
|
|
# -*- sh -*-
|
2022-04-25 05:45:19 -07:00
|
|
|
# shellcheck source=lib/functions/versions.bash
|
|
|
|
. "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
|
2019-11-27 01:24:29 -07:00
|
|
|
|
2019-11-29 06:42:55 -07:00
|
|
|
asdf_help() {
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "version: %s\n\n" "$(asdf_version)"
|
2017-09-04 10:04:56 -07:00
|
|
|
cat "$(asdf_dir)/help.txt"
|
2015-05-17 00:46:56 -07:00
|
|
|
}
|
2019-11-27 01:24:29 -07:00
|
|
|
|
2019-11-29 06:42:55 -07:00
|
|
|
asdf_moto() {
|
|
|
|
cat <<EOF
|
|
|
|
|
|
|
|
"Late but latest"
|
|
|
|
-- Rajinikanth
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
asdf_extension_cmds() {
|
2021-11-15 01:03:53 -07:00
|
|
|
local plugins_path plugin_path ext_cmd_path ext_cmds plugin
|
2019-11-29 06:42:55 -07:00
|
|
|
plugins_path="$(get_plugin_path)"
|
2022-05-12 04:48:54 -07:00
|
|
|
for plugin_path in "$plugins_path"/*/; do
|
2021-11-15 01:03:53 -07:00
|
|
|
plugin="$(basename "$plugin_path")"
|
|
|
|
ext_cmd_path="$plugin_path/lib/commands"
|
2021-12-05 01:21:57 -07:00
|
|
|
ext_cmds="$(find "$ext_cmd_path" -name "command*.bash" 2>/dev/null)"
|
2021-09-23 11:47:26 -07:00
|
|
|
if [[ -n $ext_cmds ]]; then
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "\nPLUGIN %s\n" "$plugin"
|
2021-09-23 11:47:26 -07:00
|
|
|
for ext_cmd in $ext_cmds; do
|
2021-11-15 01:03:53 -07:00
|
|
|
ext_cmd_name="$(basename "$ext_cmd")"
|
|
|
|
sed "s/-/ /g;s/.bash//;s/command-*/ asdf $plugin/;" <<<"$ext_cmd_name"
|
2021-09-23 11:47:26 -07:00
|
|
|
done | sort
|
|
|
|
fi
|
|
|
|
done
|
2019-11-29 06:42:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
help_command() {
|
2020-07-31 01:47:18 -07:00
|
|
|
local plugin_name="$1"
|
|
|
|
local tool_version="$2"
|
|
|
|
local plugin_path
|
|
|
|
|
|
|
|
# If plugin name is present as first argument output plugin help info
|
|
|
|
if [ -n "$plugin_name" ]; then
|
|
|
|
plugin_path=$(get_plugin_path "$plugin_name")
|
|
|
|
|
|
|
|
if [ -d "$plugin_path" ]; then
|
|
|
|
if [ -f "${plugin_path}/bin/help.overview" ]; then
|
|
|
|
if [ -n "$tool_version" ]; then
|
|
|
|
|
|
|
|
# TODO: Refactor this code out into helper functions in utils.bash
|
|
|
|
IFS=':' read -r -a version_info <<<"$tool_version"
|
|
|
|
if [ "${version_info[0]}" = "ref" ]; then
|
|
|
|
local install_type="${version_info[0]}"
|
|
|
|
local version="${version_info[1]}"
|
|
|
|
else
|
|
|
|
local install_type="version"
|
|
|
|
|
|
|
|
if [ "${version_info[0]}" = "latest" ]; then
|
|
|
|
local version
|
2022-04-25 05:45:19 -07:00
|
|
|
version=$(latest_command "$plugin_name" "${version_info[1]}")
|
2020-07-31 01:47:18 -07:00
|
|
|
else
|
|
|
|
local version="${version_info[0]}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
local install_path
|
|
|
|
install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
|
|
|
|
|
|
|
|
(
|
|
|
|
# shellcheck disable=SC2031
|
|
|
|
export ASDF_INSTALL_TYPE=$install_type
|
|
|
|
# shellcheck disable=SC2031
|
|
|
|
export ASDF_INSTALL_VERSION=$version
|
|
|
|
# shellcheck disable=SC2031
|
|
|
|
export ASDF_INSTALL_PATH=$install_path
|
|
|
|
|
|
|
|
print_plugin_help "$plugin_path"
|
|
|
|
)
|
|
|
|
else
|
|
|
|
(print_plugin_help "$plugin_path")
|
|
|
|
fi
|
|
|
|
else
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "No documentation for plugin %s\n" "$plugin_name" >&2
|
2020-07-31 01:47:18 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2022-12-23 02:53:22 -07:00
|
|
|
printf "No plugin named %s\n" "$plugin_name" >&2
|
2020-07-31 01:47:18 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Otherwise output general asdf help
|
|
|
|
asdf_help
|
|
|
|
asdf_extension_cmds
|
|
|
|
asdf_moto
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
print_plugin_help() {
|
|
|
|
local plugin_path=$1
|
|
|
|
|
|
|
|
# Eventually @jthegedus or someone else will format the output from these
|
|
|
|
# scripts in a certain way.
|
2021-07-29 15:44:14 -07:00
|
|
|
"${plugin_path}"/bin/help.overview
|
2020-07-31 01:47:18 -07:00
|
|
|
|
|
|
|
if [ -f "${plugin_path}"/bin/help.deps ]; then
|
2021-07-29 15:44:14 -07:00
|
|
|
"${plugin_path}"/bin/help.deps
|
2020-07-31 01:47:18 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "${plugin_path}"/bin/help.config ]; then
|
2021-07-29 15:44:14 -07:00
|
|
|
"${plugin_path}"/bin/help.config
|
2020-07-31 01:47:18 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "${plugin_path}"/bin/help.links ]; then
|
2021-07-29 15:44:14 -07:00
|
|
|
"${plugin_path}"/bin/help.links
|
2020-07-31 01:47:18 -07:00
|
|
|
fi
|
2019-11-29 06:42:55 -07:00
|
|
|
}
|
|
|
|
|
2019-11-27 01:24:29 -07:00
|
|
|
help_command "$@"
|