34ef55ed558ebae8d97187072c31caf461fe63c2
[drupal-init-tools.git] / libexec / clean.sh
1 #!/bin/bash
2 # Clean up a Drupal project directory
3 #
4 # Copyright (C) 2017  Antonio Ospite <ao2@ao2.it>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 set -e
20
21 usage() {
22   cat <<EOF
23 usage: drin $(basename $0 .sh) [-h|--help]
24
25 Cleanup the project, removing all the installed files.
26
27 Options:
28   -h, --help          display this usage message and exit
29 EOF
30 }
31
32 while [ $# -gt 0 ];
33 do
34   case "$1" in
35     -h|--help)
36       usage
37       exit 0
38       ;;
39     -*)
40       echo "Error: Unknown option '${1}'" 1>&2
41       ;;
42   esac
43   shift
44 done
45
46 CONFIRMATION_STRING="YESIAMSURE"
47
48 echo "WARNING! This removes any files in the config/ web/ and vendor/ directories."
49 echo "Are you sure you want to continue?"
50 echo
51 read -p "Type ${CONFIRMATION_STRING} to confirm: " INPUT
52
53 run() {
54   echo $*
55   $*
56 }
57
58 [ "$INPUT" = "$CONFIRMATION_STRING" ] && run sudo rm -rf config/ web/ vendor/ composer.lock