change_rust_src.sh 837 B

123456789101112131415161718192021222324252627282930313233
  1. echo "正在为rust换源"
  2. echo "bash change_rust_src.sh --sparse以使用稀疏索引"
  3. sparse="false"
  4. while true; do
  5. if [ -z "$1" ]; then
  6. break;
  7. fi
  8. case "$1" in
  9. "--sparse")
  10. echo "使用稀疏索引"
  11. sparse=""
  12. ;;
  13. esac
  14. shift 1
  15. done
  16. if [ -z ${sparse} ]; then
  17. echo -e "[source.crates-io] \n \
  18. registry = \"https://github.com/rust-lang/crates.io-index\" \n \
  19. \n \
  20. replace-with = 'tuna' \n \
  21. [source.tuna] \n \
  22. registry = \"sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/\" \n \
  23. " > ~/.cargo/config.toml
  24. else
  25. echo -e "[source.crates-io] \n \
  26. registry = \"https://github.com/rust-lang/crates.io-index\" \n \
  27. \n \
  28. replace-with = 'tuna' \n \
  29. [source.tuna] \n \
  30. registry = \"https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git\" \n \
  31. " > ~/.cargo/config.toml
  32. fi