-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.sh
executable file
·82 lines (67 loc) · 2.07 KB
/
setup.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
#!/bin/bash
# Color constants
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
# Global constants
REPO_URL="https://github.com/ndr3www/git-conform"
BIN_PATH="/usr/bin/git-conform"
LOCAL_SHARE_PATH="$HOME/.local/share/git-conform"
# Print messages with color
printcl() {
local color=$1
local message=$2
printf "%b%s%b\n" "${color}" "${message}" "${NC}"
}
# Install the git-conform CLI
install_git_conform() {
printcl "${YELLOW}" "Installing The CLI into ${BIN_PATH}..."
# Download the binary
if ! sudo wget -q --show-progress -O "${BIN_PATH}" "${REPO_URL}/releases/latest/download/git-conform"; then
printcl "${YELLOW}" "Error: Failed to download the binary."
return 1
fi
# Make the binary executable
if ! sudo chmod +x "${BIN_PATH}"; then
printcl "${YELLOW}" "Error: Failed to make git-conform executable."
return 1
fi
printcl "${GREEN}" "Installed Successfully! Run the CLI with the command: git-conform --help"
}
# Uninstall the git-conform CLI
uninstall_git_conform() {
printcl "${YELLOW}" "Uninstalling The CLI from ${BIN_PATH} and ${LOCAL_SHARE_PATH}..."
# Remove the binary
if ! sudo rm -f "${BIN_PATH}"; then
printcl "${YELLOW}" "Error: Failed to remove the binary at ${BIN_PATH}."
return 1
fi
# Remove the local share data
if ! rm -rf "${LOCAL_SHARE_PATH}"; then
printcl "${YELLOW}" "Error: Failed to remove the local share data at ${LOCAL_SHARE_PATH}."
return 1
fi
printcl "${GREEN}" "Uninstalled Successfully!"
}
# Main function to choose an action
main() {
printcl "${YELLOW}" "Choose an action:"
printcl "${YELLOW}" "1: Install"
printcl "${YELLOW}" "2: Uninstall"
read -r -p "Enter your choice: " choice
case "$choice" in
1)
install_git_conform
;;
2)
uninstall_git_conform
;;
*)
printcl "${YELLOW}" "Invalid choice. Please choose 1 to install or 2 to uninstall."
exit 1
;;
esac
}
# Run the main function
main
exit 0