OSDN Git Service

Hulk did something
[bytom/vapor.git] / vendor / github.com / spf13 / pflag / verify / all.sh
1 #!/bin/bash
2
3 set -o errexit
4 set -o nounset
5 set -o pipefail
6
7 ROOT=$(dirname "${BASH_SOURCE}")/..
8
9 # Some useful colors.
10 if [[ -z "${color_start-}" ]]; then
11   declare -r color_start="\033["
12   declare -r color_red="${color_start}0;31m"
13   declare -r color_yellow="${color_start}0;33m"
14   declare -r color_green="${color_start}0;32m"
15   declare -r color_norm="${color_start}0m"
16 fi
17
18 SILENT=true
19
20 function is-excluded {
21   for e in $EXCLUDE; do
22     if [[ $1 -ef ${BASH_SOURCE} ]]; then
23       return
24     fi
25     if [[ $1 -ef "$ROOT/hack/$e" ]]; then
26       return
27     fi
28   done
29   return 1
30 }
31
32 while getopts ":v" opt; do
33   case $opt in
34     v)
35       SILENT=false
36       ;;
37     \?)
38       echo "Invalid flag: -$OPTARG" >&2
39       exit 1
40       ;;
41   esac
42 done
43
44 if $SILENT ; then
45   echo "Running in the silent mode, run with -v if you want to see script logs."
46 fi
47
48 EXCLUDE="all.sh"
49
50 ret=0
51 for t in `ls $ROOT/verify/*.sh`
52 do
53   if is-excluded $t ; then
54     echo "Skipping $t"
55     continue
56   fi
57   if $SILENT ; then
58     echo -e "Verifying $t"
59     if bash "$t" &> /dev/null; then
60       echo -e "${color_green}SUCCESS${color_norm}"
61     else
62       echo -e "${color_red}FAILED${color_norm}"
63       ret=1
64     fi
65   else
66     bash "$t" || ret=1
67   fi
68 done
69 exit $ret