Make wrapper work for simple usecase

This commit is contained in:
2021-12-21 02:00:48 -08:00
parent c7e09adba2
commit bb695de69f
5 changed files with 294 additions and 3 deletions

29
View File

@@ -49,6 +49,35 @@ _bad-message() {
echo -e "\e[31m$@\e[0m"
}
_wrapper() {
unset OPTIND
while getopts "l:d:n:v:" opt; do
case $opt in
l) linux_url=$OPTARG ;;
d) darwin_url=$OPTARG ;;
n) name=$OPTARG ;;
v) version=$OPTARG ;;
esac
done
while [[ -n "$1" && "$1" != "--" ]]; do
shift
done
shift
if [[ $(uname -s) == Linux ]]; then
url=$linux_url
else
url=$darwin_url
fi
wrapper_root=".generated/wrapper/$name/$version/"
mkdir -p $wrapper_root
[[ -f $wrapper_root/bin ]] || curl --location ${url//VERSION/$version} > $wrapper_root/bin
chmod +x $wrapper_root/bin
./$wrapper_root/bin "$@"
}
[[ $(type -t _verify-prerequisites) == "function" ]] && ! _verify-prerequisites && exit 1
main "$@"