-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.inc.bash
85 lines (80 loc) · 3.1 KB
/
options.inc.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
cd $DIR;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
singleToolToRun=
specifiedPath=
function usage {
echo "Usage:"
echo "bin/qa [-t tool to run ] [ -p path to scan ]"
echo ""
echo "Defaults to using all tools and scanning whole project based on platform"
echo ""
echo " - use -h to see this help"
echo ""
echo " - use -p to specify a specific path to scan"
echo ""
echo " - use -t to specify a single tool:"
echo " psr|psr4 psr4 validation"
echo " com|composer composer validation"
echo " st|stricttypes strict types validation"
echo " lint|phplint phplint"
echo " stan|phpstan phpstan"
echo " ann|phpunitAnnotations phpunitAnnotations"
echo " unit|phpunit phpunit"
echo " uniterate phpunit iterative mode - prioritise broken tests and fail on error"
echo " infect|infection infection"
echo " md|messdetector php mess detector"
echo " ml|markdown markdown validation"
echo " bf|phpbf php beautifier and fixer"
echo " cs|phpcs php code sniffer"
echo " l|loc lines of code and other stats"
exit 1
}
while getopts ":t:p:h" opt; do
case "$opt" in
t) singleToolToRun=$OPTARG ;;
p) specifiedPath=$OPTARG ;;
h) usage ;;
\?)
printf "\nERROR:\nInvalid option: -$OPTARG\n\n" >&2
usage
;;
:)
printf "\nERROR\nOption -$OPTARG requires an argument\n\n" >&2
usage
;;
esac
done
if [[ "" != "$singleToolToRun" ]]
then
case "$singleToolToRun" in
psr | psr4 ) singleToolToRun="psr4Validate";;
com | composer ) singleToolToRun="composerChecks";;
st | stricttypes ) singleToolToRun="phpStrictTypes";;
lint | phplint ) singleToolToRun="phpLint";;
stan | phpstan ) singleToolToRun="phpstan";;
ann | phpunitAnnotations ) singleToolToRun="phpunitAnnotations";;
unit | phpunit ) singleToolToRun="phpunit";;
uniterate ) singleToolToRun="phpunit"; phpUnitIterativeMode=1;;
infect | infection ) singleToolToRun="infection";;
md | messdetector ) singleToolToRun="messDetector";;
ml | markdown ) singleToolToRun="markdownLinks";;
bf | phpbf ) singleToolToRun="beautifierFixer";;
cs | phpcs ) singleToolToRun="codeSniffer";;
l | loc ) singleToolToRun="phploc";;
* )
printf "\nERROR:\nInvalid tool: $singleToolToRun\n\n" >&2
usage
;;
esac
echo "Running Single Tool: $singleToolToRun"
fi
if [[ "" != "$specifiedPath" ]]
then
echo "Scanning Specified Path: $specifiedPath"
fi