-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch-composer
executable file
·70 lines (57 loc) · 1.58 KB
/
switch-composer
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
#!/bin/bash
#---------- Varibles ----------
# Colours
endColor="\e[0m\e[0m"
redColor="\e[0;31m\e[1m"
cyanColor="\e[01;96m\e[1m"
greenColor="\e[0;32m\e[1m"
yellowColor="\e[0;33m\e[1m"
dot="${redColor}[${endColor}${yellowColor}*${endColor}${redColor}] ${endColor}"
# CTRL + C
trap ctrl_c INT
function ctrl_c() {
echo -e "\n\n${dot}${yellowColor}Exiting...${endColor}"
exit
}
# Prompt
prompt=$(echo -e "${redColor}\n┌─[${cyanColor}Please select the composer version you want to switch to${endColor}${redColor}]\n└──╼ ${endColor}")
#---------- Switch Function ----------
function composerSwitcher() {
echo -e "\n${dot}${yellowColor}Switching to composer$1${endColor}"
sudo composer self-update --$1
composer --version
}
#---------- Script Functions ----------
function menu() {
echo -e "${greenColor}"
echo "#####################################"
echo " Current composer version is "
echo -e "${endColor}"
composer --version
echo -e "${greenColor}"
echo "#####################################"
echo -e "${endColor}"
echo -e "\n${yellowColor}1) ${endColor}${greenColor}Composer 1${endColor}"
echo -e "${yellowColor}2) ${endColor}${greenColor}Composer 2${endColor}"
echo -e "${yellowColor}q) ${endColor}${greenColor}Exit${endColor}"
if [ "$error" == "0" ]; then
echo -e "\n\n${dot}${yellowColor}Option does not exist, retry${endColor}";
fi;
read -p "$prompt" option
}
function run() {
menu
case $option in
1) composerSwitcher "1";
;;
2) composerSwitcher "2";
;;
q) exit 0
;;
*)
error="0"
menu
;;
esac
}
run