ambevar-dotfiles/.scripts/git-get

54 lines
832 B
Bash
Executable File

#!/bin/sh
_printhelp ()
{
cat<<EOF
Usage: ${1##*/} [OPTIONS] REPOS
Clone multiple git repos from \$DOMAIN:\$USER.
Synopsis:
-h: Show this help.
-d DOMAIN: Set domain.
-u USER: Set the repository owner.
EOF
}
DOMAIN=bitbucket.org
USER=ambrevar
while getopts ":hd:u:" opt; do
case $opt in
h)
_printhelp "$0"
exit 1 ;;
d)
DOMAIN=$OPTARG ;;
u)
USER=$OPTARG ;;
?)
_printhelp "$0"
exit 1 ;;
:)
_printhelp "$0"
exit 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then
_printhelp "$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