Untitled

mail@pastecode.io avatar
unknown
sh
3 years ago
603 B
2
Indexable
Never
#!/bin/bash

while getopts ":n:p:c:" opt; do
  case $opt in
    n) name="$OPTARG"
    ;;
    p) max="$OPTARG"
    ;;
    c) cntx="$OPTARG"
    ;;
    \?) echo "Invalid option -$OPTARG" >&2
    exit 1
    ;;
  esac
done

if [ -n $name ]; then
  exit 1
fi

max=${max:-"1"}
cntx=${cntx:-"orgs"} #users|orgs

echo $name
echo $max
echo $cntx

set -x
for page in $(seq $max); do
  curl  -u brunomiranda-hotmart:$TOKEN "https://api.github.com/$cntx/$name/repos?page=$page&per_page=100" -s | grep -e 'git_url*' | cut -d \" -f 4 | sed "s#://#@#g" | sed "s#.com/#.com:#g" | xargs -L1 git clone
done
set +x

exit 0