ambevar-dotfiles/.scripts/git-get

51 lines
626 B
Bash
Executable File

#!/bin/sh
DOMAIN=bitbucket.org
USER=ambrevar
usage() {
cat<<EOF
Usage: ${1##*/} [OPTIONS] REPOS
Clone git repo(s) from $DOMAIN:$USER.
Options:
-h: Show this help.
-d DOMAIN: Set domain.
-u USER: Set repository owner.
EOF
}
while getopts ":hd:u:" opt; do
case $opt in
h)
usage "$0"
exit 1 ;;
d)
DOMAIN=$OPTARG ;;
u)
USER=$OPTARG ;;
\?)
usage "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
usage "$0"
exit 1
fi
if ! command -v git >/dev/null 2>&1; then
echo >&2 "'git' not found in PATH. Exiting."
exit 1
fi
for i; do
git clone git@$DOMAIN:/$USER/$i
done