#!/bin/bash -e function usage() { cat <> ~/.bashrc if [ -e ~/.zshrc ] then echo "PATH=\"$PWD/bin:\$PATH\"" >> ~/.zshrc fi ;; list) for t in * do [ ! -e "$t/install" ] && continue echo $t done ;; bin) cd bin ln -sf ../$TOOL/bin/* . echo "TOOLS | $TOOL | bin symlinks updated" cd .. ;; install) cd $TOOL if git status --ignored . | egrep -q 'Untracked|Ignored' then echo "TOOLS | $TOOL | appears to already be installed. Uninstall first?" exit 0 fi echo "TOOLS | $TOOL | starting install" [ -x ./install-root -a "$ALLOW_SUDO" -eq 1 ] && sudo ./install-root ./install echo "TOOLS | $TOOL | install finished" cd .. $0 bin $TOOL ;; uninstall) cd $TOOL [ -x ./uninstall ] && ./uninstall git clean -dffx . echo "TOOLS | $TOOL | uninstall finished" cd .. ;; upgrade) cd $TOOL if [ -x ./upgrade ] then ./upgrade echo "TOOLS | $TOOL | upgrade complete!" else echo "TOOLS | $TOOL | no upgrade script -- reinstalling" $0 uninstall $TOOL $0 install $TOOL fi ;; reinstall) $0 uninstall $TOOL $0 install $TOOL ;; search) cat README.md | grep "<\!--tool-->" | sed "s/<\!--[^-]*-->//g" | grep -i "$TOOL" ;; test) if ! cat README.md | grep "<\!--tool-->" | grep "| \[$TOOL\](" | grep -q -- "--test--" then echo "TOOLS | $TOOL | Tests not enabled." else [ "$ALLOW_SUDO" -eq 1 ] && $0 -s install $TOOL [ "$ALLOW_SUDO" -eq 0 ] && $0 install $TOOL cd $TOOL if [ -f ./test ] then echo "TOOLS | $TOOL | Running test script." ./test echo "TOOLS | $TOOL | test script succeeded!" exit 0 else echo "TOOLS | $TOOL | Install succeeded. No test script!" exit 0 fi fi ;; *) echo "TOOLS | ERROR | unknown action $ACTION" ;; esac