Support project build from URL (closes #14)

This commit is contained in:
southerntofu 2020-04-29 16:38:27 +02:00
parent 04071c907f
commit 5a5eed8c7c
1 changed files with 12 additions and 0 deletions

View File

@ -36,8 +36,20 @@ PROJECTS=()
for arg in "$@"; do
if [[ "$arg" = "-f" ]] || [[ "$arg" = "--force" ]]; then
FORCE=1
# Maybe it's a task name and we find a corresponding source?
elif [ -f $BASEDIR/$arg.source ]; then
PROJECTS+=("$arg")
# Maybe it's a repo URL and we find a corresponding task?
elif matches="$(grep --files-with-matches --word-regexp "$arg" $BASEDIR/*.source)"; then
# Iterate over the files found to extract the task name
IFS= echo "$matches" | while read -r file; do
task_name="$(basename "$file" .source)"
# Make sure we don't have a .source file without name lying around, just in case
[[ "$task_name" != "" ]] && PROJECT+=("$task_name")
done
else
echo "ERROR: Unknown argument '$arg' (doesn't match a task name or source URL)"
exit 1
fi
done