From 8b71deee751855ea5bc4ee87f93b03a432860636 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 4 Jan 2022 13:45:12 -0600 Subject: [PATCH] update tools installer for eget v1.0.0 --- info/tools.yml | 18 ++++++++---- tools.sh | 74 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 63 insertions(+), 29 deletions(-) diff --git a/info/tools.yml b/info/tools.yml index 8c53983..0c992e0 100644 --- a/info/tools.yml +++ b/info/tools.yml @@ -43,6 +43,13 @@ glab: #node fnm: user: Schniz + download-only: true + post-download: | + unzip -qq fnm-linux.zip + mv fnm $EGET_BIN/fnm + rm -r fnm-linux.zip + chmod u+x $EGET_BIN/fnm + # editing neovim: @@ -51,11 +58,12 @@ neovim: # file management gdu: user: dundee - download-only: true - post-download: | - tar -xzf gdu_linux_amd64.tgz - mv gdu_linux_amd64 $EGET_BIN/gdu - rm gdu_linux_amd64.tgz + to: gdu +# download-only: true +# post-download: | +# tar -xzf gdu_linux_amd64.tgz +# mv gdu_linux_amd64 $EGET_BIN/gdu +# rm gdu_linux_amd64.tgz lf: user: gokcehan diff --git a/tools.sh b/tools.sh index ce59084..a526bc9 100755 --- a/tools.sh +++ b/tools.sh @@ -3,6 +3,8 @@ BIN_DIR=$HOME/bin mkdir -p $BIN_DIR EGET_BIN=$BIN_DIR +YAMLDOC="info/tools.yml" +alias eget="eget --system linux/amd64" post_download_install() { @@ -14,6 +16,36 @@ post_download_install() { } +eget_tool() { + + tool=$1 + + echo -n $tool + + user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC) + asset=$(key=$tool yq e 'explode(.) | .[env(key)].asset // ""' $YAMLDOC) + file=$(key=$tool yq e 'explode(.) | .[env(key)].file // ""' $YAMLDOC) + to=$(key=$tool yq e 'explode(.) | .[env(key)].to // ""' $YAMLDOC) + download_only=$(key=$tool yq e 'explode(.) | .[env(key)].download-only // ""' $YAMLDOC) + + eget $user/$tool \ + ${asset:+--asset $asset} \ + ${file:+--file $file} \ + ${to:+--to $to}\ + ${download_only:+--download-only} \ + -q + + if [[ $download_only ]]; then + echo -n ' --> ' + echo -n 'running post-download script' + post_download_install $tool + fi + + echo +} + + + if ! $(is-executable eget); then echo "I don't see eget on your path..." read -p "Do you want to download it to ${BIN_DIR}? " -n 1 -r @@ -33,33 +65,27 @@ if ! $(is-executable yq); then eget mikefarah/yq --asset yq_linux_amd64 fi -YAMLDOC="info/tools.yml" -alias eget="eget --system linux/amd64" + +if ! [ -z "$1" ]; then + tool=$1 + + echo "installing $tool" + info=$(key=$tool yq e 'explode(.) | .[env(key)]' $YAMLDOC) + if [[ "$info" == "null" ]]; then + echo "$tool not found in $YAMLDOC" + echo "exiting" + exit 1 + else + eget_tool $tool + fi + exit +fi + +echo "no tool specified installing everything" readarray tools < <(yq e 'keys | .[]' $YAMLDOC) for tool in "${tools[@]:1}" do - echo -n $tool - - user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC) - asset=$(key=$tool yq e 'explode(.) | .[env(key)].asset // ""' $YAMLDOC) - file=$(key=$tool yq e 'explode(.) | .[env(key)].file // ""' $YAMLDOC) - to=$(key=$tool yq e 'explode(.) | .[env(key)].to // ""' $YAMLDOC) - download_only=$(key=$tool yq e 'explode(.) | .[env(key)].download-only // ""' $YAMLDOC) - - eget $user/$tool \ - ${asset:+--asset $asset} \ - ${file:+--file $file} \ - ${to:+--to $to}\ - ${download_only:+--download-only} \ - -q - - if [[ $download_only ]]; then - echo -n '-->' - echo -n 'running post-download script' - post_download_install $tool - fi - - echo + eget_tool $tool done