clean.sh 943 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. #
  4. # Functions
  5. #
  6. __usage() {
  7. echo "Usage: $(basename "${BASH_SOURCE[0]}") <Arguments>
  8. Arguments:
  9. <Arguments>... Arguments passed to the 'git' command. Any number of arguments allowed.
  10. Description:
  11. This script cleans the repository interactively, leaving downloaded infrastructure untouched.
  12. Clean operation is interactive to avoid losing new but unstaged files. Press 'c' then [Enter]
  13. to perform the proposed deletions.
  14. "
  15. }
  16. git_args=()
  17. while [[ $# -gt 0 ]]; do
  18. case $1 in
  19. -\?|-h|--help)
  20. __usage
  21. exit 0
  22. ;;
  23. *)
  24. git_args[${#git_args[*]}]="$1"
  25. ;;
  26. esac
  27. shift
  28. done
  29. # This incantation avoids unbound variable issues if git_args is empty
  30. # https://stackoverflow.com/questions/7577052/bash-empty-array-expansion-with-set-u
  31. git clean -dix -e .dotnet/ -e .tools/ ${git_args[@]+"${git_args[@]}"}