|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +function strapped_asdf() { |
| 4 | + # Variables to hold the deps and corresponding checks |
| 5 | + local __deps="asdf " |
| 6 | + local __resp |
| 7 | + # Performing each check for each dep |
| 8 | + for dep in ${__deps}; do |
| 9 | + command -v "${dep}" &> /dev/null |
| 10 | + __resp=$? |
| 11 | + if [[ $__resp -ne 0 ]]; then |
| 12 | + echo "ERROR: dep ${dep} not found:" |
| 13 | + case "${dep}" in |
| 14 | + "asdf") |
| 15 | + echo -e " |
| 16 | + Please ensure you have asdf installed on your system |
| 17 | + To install asdf, follow the instructions at https://asdf-vm.com/#/core-manage-asdf-vm |
| 18 | +" |
| 19 | + ;; |
| 20 | + esac |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | + done |
| 24 | + |
| 25 | + # Declaring local variables for the 'plugins' routine |
| 26 | + local name |
| 27 | + local url |
| 28 | + |
| 29 | + # Declaring local variables for the 'versions' routine |
| 30 | + local dir |
| 31 | + local name |
| 32 | + local version |
| 33 | + local input=${1} |
| 34 | + |
| 35 | + # Initialize array iterator |
| 36 | + local i=0 |
| 37 | + |
| 38 | + # performing functionality for routine 'plugins' |
| 39 | + for ((i=0; i<$( ysh -T "${input}" -c plugins ); i++)); do |
| 40 | + |
| 41 | + # Getting fields for routine 'plugins' |
| 42 | + name=$( ysh -T "${input}" -l plugins -i ${i} -Q name ) |
| 43 | + url=$( ysh -T "${input}" -l plugins -i ${i} -Q url ) |
| 44 | + |
| 45 | + # Writing message for routine 'plugins' |
| 46 | + pretty_print ":info:" "🐙 adding ${name} plugin to asdf" |
| 47 | + |
| 48 | + # Executing the command(s) for routine 'plugins' |
| 49 | + run_command "asdf plugin-add ${name} ${url}" |
| 50 | + done |
| 51 | + |
| 52 | + |
| 53 | + # performing functionality for routine 'versions' |
| 54 | + for ((i=0; i<$( ysh -T "${input}" -c versions ); i++)); do |
| 55 | + |
| 56 | + # Getting fields for routine 'versions' |
| 57 | + dir=$( ysh -T "${input}" -l versions -i ${i} -Q dir ) |
| 58 | + name=$( ysh -T "${input}" -l versions -i ${i} -Q name ) |
| 59 | + version=$( ysh -T "${input}" -l versions -i ${i} -Q version ) |
| 60 | + |
| 61 | + # Writing message for routine 'versions' |
| 62 | + pretty_print ":info:" "⌨ shimming ${name} to ${version}" |
| 63 | + |
| 64 | + # Executing the command(s) for routine 'versions' |
| 65 | + run_command "test '${dir}' && (cd ${dir} && asdf local ${name} ${version}) || asdf global global ${name} ${version}" |
| 66 | + done |
| 67 | +} |
0 commit comments