tools fmt

This commit is contained in:
Daylin Morgan 2022-01-09 18:16:55 -06:00
parent 35fb1fc84b
commit ec3556e91b

View file

@ -8,50 +8,47 @@ alias eget="eget --system linux/amd64"
post_download_install() { post_download_install() {
tool=$1 tool=$1
temp_file=$(mktemp -p . ${tool}.XXX.sh) temp_file=$(mktemp -p . ${tool}.XXX.sh)
key=$tool yq e 'explode(.) | .[env(key)].post-download' $YAMLDOC > $temp_file key=$tool yq e 'explode(.) | .[env(key)].post-download' $YAMLDOC >$temp_file
. $temp_file . $temp_file
rm $temp_file rm $temp_file
} }
eget_tool() { eget_tool() {
tool=$1 tool=$1
echo -n $tool echo -n $tool
user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC) user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC)
asset=$(key=$tool yq e 'explode(.) | .[env(key)].asset // ""' $YAMLDOC) asset=$(key=$tool yq e 'explode(.) | .[env(key)].asset // ""' $YAMLDOC)
file=$(key=$tool yq e 'explode(.) | .[env(key)].file // ""' $YAMLDOC) file=$(key=$tool yq e 'explode(.) | .[env(key)].file // ""' $YAMLDOC)
to=$(key=$tool yq e 'explode(.) | .[env(key)].to // ""' $YAMLDOC) to=$(key=$tool yq e 'explode(.) | .[env(key)].to // ""' $YAMLDOC)
download_only=$(key=$tool yq e 'explode(.) | .[env(key)].download-only // ""' $YAMLDOC) download_only=$(key=$tool yq e 'explode(.) | .[env(key)].download-only // ""' $YAMLDOC)
eget $user/$tool \ eget $user/$tool \
${asset:+--asset $asset} \ ${asset:+--asset $asset} \
${file:+--file $file} \ ${file:+--file $file} \
${to:+--to $to}\ ${to:+--to $to} \
${download_only:+--download-only} \ ${download_only:+--download-only} \
-q -q
if [[ $download_only ]]; then if [[ $download_only ]]; then
echo -n ' --> ' echo -n ' --> '
echo -n 'running post-download script' echo -n 'running post-download script'
post_download_install $tool post_download_install $tool
fi fi
echo echo
} }
if ! $(is-executable eget); then if ! $(is-executable eget); then
echo "I don't see eget on your path..." echo "I don't see eget on your path..."
read -p "Do you want to download it to ${BIN_DIR}? " -n 1 -r read -p "Do you want to download it to ${BIN_DIR}? " -n 1 -r
echo # (optional) move to a new line echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]] if [[ ! $REPLY =~ ^[Yy]$ ]]; then
then
exit 1 exit 1
else else
curl https://zyedidia.github.io/eget.sh | sh curl https://zyedidia.github.io/eget.sh | sh
@ -62,30 +59,28 @@ fi
echo "downloading binaries from github to $EGET_BIN" echo "downloading binaries from github to $EGET_BIN"
if ! $(is-executable yq); then if ! $(is-executable yq); then
eget mikefarah/yq --asset yq_linux_amd64 eget mikefarah/yq --asset yq_linux_amd64
fi fi
if ! [ -z "$1" ]; then if ! [ -z "$1" ]; then
tool=$1 tool=$1
echo "installing $tool" echo "installing $tool"
info=$(key=$tool yq e 'explode(.) | .[env(key)]' $YAMLDOC) info=$(key=$tool yq e 'explode(.) | .[env(key)]' $YAMLDOC)
if [[ "$info" == "null" ]]; then if [[ $info == "null" ]]; then
echo "$tool not found in $YAMLDOC" echo "$tool not found in $YAMLDOC"
echo "exiting" echo "exiting"
exit 1 exit 1
else else
eget_tool $tool eget_tool $tool
fi fi
exit exit
fi fi
echo "no tool specified installing everything" echo "no tool specified installing everything"
readarray tools < <(yq e 'keys | .[]' $YAMLDOC) readarray tools < <(yq e 'keys | .[]' $YAMLDOC)
for tool in "${tools[@]:1}" for tool in "${tools[@]:1}"; do
do eget_tool $tool
eget_tool $tool
done done