-
Notifications
You must be signed in to change notification settings - Fork 0
/
panterm.sh
executable file
·161 lines (141 loc) · 3.24 KB
/
panterm.sh
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
# panterm
#
# scripts for pantheon sites
#
# usage:
# ./panterm.sh <script> [sitename] [arguments]
#
# set colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
BLACK='\033[0;30m'
DARK_GRAY='\033[1;30m'
LIGHT_GRAY='\033[0;37m'
WHITE='\033[1;37m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
# set styles for output
BOLD='\033[1m'
DIM='\033[2m'
ITALIC='\033[3m'
UNDERLINE='\033[4m'
BLINK='\033[5m'
REVERSE='\033[7m'
HIDDEN='\033[8m'
STRIKETHROUGH='\033[9m'
# no color to reset
NC='\033[0m'
##
# functions
##
# function to display the help message
show_help() {
echo -e "${CYAN}panterm - pantheon + terminus scripts${NC}"
echo -e "${YELLOW}usage:${NC}"
echo -e "./panterm.sh <script> [SITENAME] [ARGUMENTS]"
echo
echo -e "${YELLOW}scripts:${NC}"
echo -e "${GREEN}review${NC} pulls down a site into ddev and merges PR in for testing"
echo -e "${GREEN}update${NC} runs pantheon updates"
echo
echo
echo -e "${CYAN}review script${NC}"
echo -e "${YELLOW}usage:${NC}"
echo -e "./panterm.sh review [SITENAME] [PR]"
echo
echo -e "${YELLOW}arguments:${NC}"
echo -e "${GREEN}SITENAME${NC} site to test the pr on"
echo -e "${GREEN}PR${NC} pull request number [0-9+]"
echo
echo
echo -e "${CYAN}update script${NC}"
echo -e "${YELLOW}usage:${NC}"
echo -e "./panterm.sh update [SITENAME] [ARGUMENTS]"
echo
echo -e "${YELLOW}arguments:${NC}"
echo -e "${GREEN}SITENAME${NC} site to update"
echo -e "${GREEN}-nc|--no-check${NC} disable update prompts"
echo
echo
echo -e "${YELLOW}${ITALIC}if no SITENAME, PR, or ARGUMENTS passed will prompt${NC}"
echo
}
##
# main
##
#
# checking arguments
#
# make sure have enough args to get started or show help
if [ "$#" -lt 1 ]; then
show_help
#echo "usage: $0 <script> <sitename - optional> [additional arguments...]"
#echo "script: review or update"
exit 0
fi
# set the gen vars
DIR_LIB="./lib"
# set the vars from args
SCRIPT=$1
SITENAME=$2
# check which script to run
case "$SCRIPT" in
-h|--help)
show_help
exit 0
;;
review)
if [ -z "$SITENAME" ]; then
# remove vars and pass others off
shift 1
"$DIR_LIB/review.sh" "$@"
else
# remove vars and pass others off
shift 2
"$DIR_LIB/review.sh" "$SITENAME" "$@"
fi
;;
update)
if [ -z "$SITENAME" ]; then
# remove vars and pass others off
shift 1
"$DIR_LIB/update.sh" "$@"
else
# remove vars and pass others off
shift 2
"$DIR_LIB/update.sh" "$SITENAME" "$@"
fi
;;
*)
echo "Unknown script: $SCRIPT. Use 'review' or 'update'."
exit 1
;;
esac
# FROM UPDATE.SH
##
# main
##
main() {
# parse command line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
show_help
exit 0
;;
review)
if [ -z "$2" ]; then
"./lib/review.sh" "$@"
shift
else
"./lib/review.sh" "$2" "$@"
shift
fi
;;
esac
done
}
main "$@"; exit 0