#!/bin/sh

root="https://github.com/jonof"
pushroot="$root"
projects="jfbuild jfmact jfaudiolib jfduke3d jfsw"

while [ $# -gt 0 ]; do
    case $1 in
        --help)
            echo "JF-ports Git repository cloning helper"
            echo "$0 [--help] [--git] [--projects \"list of projects\"]"
            echo "  --help          this text"
            echo "  --git           use the 'git' protocol for cloning instead of http"
            echo "  --projects xxx  clone the (space separated) list of projects"
            exit
            ;;
	--git)
	    root="git://github.com/jonof"
            pushroot="git@github.com:jonof"
            ;;
        --projects)
            shift
            projects="$1"
            ;;
    esac
    shift
done

echo "root = $root"
echo "projects = $projects"
echo

for project in $projects; do
    git clone $root/$project.git $project.git
    if [ "$root" != "$pushroot" ]; then
        cd $project.git
        git config remote.origin.pushurl $pushroot/$project.git
        cd ..
    fi
    echo
done

