Skip to content

Instantly share code, notes, and snippets.

@vampirechicken
Last active September 18, 2015 16:32
Show Gist options
  • Save vampirechicken/51f7397918034d9d1997 to your computer and use it in GitHub Desktop.
Save vampirechicken/51f7397918034d9d1997 to your computer and use it in GitHub Desktop.
makeloop is to continuous integration testing as crawling is to roller skating.
#!/bin/bash
TARGET="${1:-all}"
LAST_TARGET=$TARGET
MAKE=make
MAKEFILE=Makefile
EDIT=/usr/bin/vim
SQL=devmaptsql
PS=/bin/ps
edit_makefile() {
${EDIT} ${MAKEFILE}
}
run_sql() {
${SQL}
}
run_ps() {
${PS} -fu mapt
}
shell_out() {
${SHELL}
}
change_target() {
LAST_TARGET=${TARGET}
TARGET=${NEW_TARGET}
}
swap_targets() {
TMP=${LAST_TARGET};
LAST_TARGET=${TARGET};
TARGET=${TMP}
}
clear_plan() {
clear_tplan
}
cd ${MAPT_HOME}
while :
do
echo -en "[${LAST_TARGET}:${TARGET}] >> "
read NEW_TARGET
if [[ $? != 0 || ${NEW_TARGET} = 'q' || ${NEW_TARGET} = ':q' ]]; then
echo
exit
fi
if [[ ${NEW_TARGET} == 'vi' ]]; then
edit_makefile
continue;
elif [[ ${NEW_TARGET} == '!vi' ]]; then
edit_makefile
continue;
elif [[ ${NEW_TARGET} == 'edit' ]]; then
edit_makefile
continue;
elif [[ ${NEW_TARGET} == 'sql' ]]; then
run_sql
continue;
elif [[ ${NEW_TARGET} == 'ps' ]]; then
run_ps
continue;
elif [[ ${NEW_TARGET} == 'ct' ]]; then
clear_plan
continue;
elif [[ ${NEW_TARGET} == '!' ]]; then
shell_out
continue;
elif [[ ${NEW_TARGET} == '-' ]]; then
swap_targets
continue
elif [[ ${NEW_TARGET} != '' ]]; then
change_target
continue
fi
echo `date` '*************************************************'
time ${MAKE} ${TARGET}
date
done
@vampirechicken
Copy link
Author

makeloop is to continuous integration as crawling is to roller skating.

it puts awhile loop around make, and stops for input after each iteration, allowing you to:
'' - run another iteration
'q' or EOF - quit
'edit', 'vi', or '!vi' - edit the makefile
! - shell out
sql - launch sql client
ps - run ps --fu ${user}
'-' - swap the current make target for the previous make target
anything else - change the make target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment