暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

rustfmt.sh 911B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. # Checks
  3. # - rustfmt
  4. # config
  5. FOLDER="hw*"
  6. FILES='.+\.(rs)'
  7. # Exit script on the first error
  8. set -o errexit -o nounset
  9. ERROR=0
  10. # cross platform compatible find
  11. function find_files() {
  12. if [[ "$OSTYPE" == "linux-gnu" ]]; then
  13. find . -regextype posix-extended -path "./$FOLDER" -iregex $FILES -print0
  14. elif [[ "$OSTYPE" == "darwin"* ]]; then
  15. find -E . -path "./$FOLDER" -iregex $FILES -print0
  16. fi
  17. }
  18. ### rustfmt ===================================
  19. echo ""
  20. echo "=== Searching for files with rustfmt warnings ========================"
  21. FOUND=0
  22. while IFS= read -r -d '' f; do
  23. rustfmt --write-mode=diff "$f" || FOUND=1
  24. done < <(find_files)
  25. if [ $FOUND -eq 0 ] ; then
  26. echo "=== None found! :-)"
  27. else
  28. echo ""
  29. echo "!!! Some files with rust format warninge were found."
  30. echo "!!! Please correct format in these files by running rustfmt!"
  31. ERROR=1
  32. fi
  33. test $ERROR == 0