Created
February 10, 2015 10:14
-
-
Save alexlee002/f0a3af04cd86ca1d9f77 to your computer and use it in GitHub Desktop.
Switch Cocoapods' repo mirrors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function usage() | |
{ | |
echo -e "Usage:\n\t$(basename $0) offical|gitcafe|oschina|<other repo url>\n\n" | |
} | |
####################################### | |
if [[ $# -lt 1 ]]; then | |
usage;exit | |
fi | |
POD_PATH=$(echo $(whereis pod)) | |
if [[ $POD_PATH = "" ]]; then | |
echo -e "\033[31;1mpod not found, Install Cocoapod first!\033[0m\n\n" | |
exit | |
fi | |
repo=$1 | |
case $repo in | |
"offical" ) | |
repo='https://github.com/CocoaPods/Specs.git' | |
;; | |
"gitcafe" ) | |
repo='https://gitcafe.com/lloydsheng/Specs.git' | |
;; | |
"oschina" ) | |
repo='http://git.oschina.net/akuandev/Specs.git' | |
;; | |
"?" ) | |
usage | |
exit | |
;; | |
":" ) | |
error "ERROR: No argument value for option $repo" | |
exit | |
;; | |
* ) | |
;; | |
esac | |
current_repo=`$POD_PATH repo list | grep '\- URL:' | awk -F ' ' '{print $NF}'` | |
if [[ $current_repo = $repo ]]; then | |
echo -e "\033[32mCurrent repo is already set to '\033[33m$repo\033[32m', no changed.\033[0m\n\n" | |
else | |
echo -e "\033[32mCurrent repo is \033[33m$current_repo\033[0m" | |
echo -e "\033[32mand will be changed to \033[35m\t$repo\033[0m\n\n" | |
if [[ $current_repo ]]; then | |
$POD_PATH repo remove master || exit 1 | |
fi | |
$POD_PATH repo add master $repo || exit 1 | |
$POD_PATH repo update --verbose || exit 1 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment