Add help flag, ensure sourceless task working dir (basedir)

This commit is contained in:
southerntofu 2020-11-25 17:51:57 +01:00
parent ec926d76bc
commit 6938e47102
1 changed files with 5 additions and 1 deletions

View File

@ -62,7 +62,7 @@ debug () {
help () {
echo "forgebuild [tasks]"
echo " Trigger updates on `tasks` (all tasks by default)"
echo " Trigger updates on \`tasks\` (all tasks by default)"
echo "ARGS:"
echo " -f: force run of tasks regardless of updates on the repository"
echo " -b BASEDIR: consider tasks from BASEDIR, not ~/.forgebuild"
@ -248,6 +248,9 @@ for arg in "$@"; do
elif [[ "$arg" = "-f" ]] || [[ "$arg" = "--force" ]]; then
info force_flag
FORCE=1
elif [[ "$arg" = "-h" ]] || [[ "$arg" = "--help" ]]; then
help
exit 0
elif [[ "$arg" = "-b" ]] || [[ "$arg" = "--basedir" ]]; then
FOUND_BASEDIR=1
elif [ -x $BASEDIR/$arg ]; then
@ -328,6 +331,7 @@ for p_name in ${PROJECTS[*]}; do
# If $p_name.done exists, the task was already run
[ -f $BASEDIR/$p_name.done ] && continue
# If the task fails, don't register the .done
cd $BASEDIR
run $p_name && touch $BASEDIR/$p_name.done
continue
fi