-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRun.command
More file actions
82 lines (72 loc) · 2.16 KB
/
Copy pathRun.command
File metadata and controls
82 lines (72 loc) · 2.16 KB
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
# Force terminal to change to the directory where this script is located
cd "$(dirname "$0")"
# Determine which python command is available
if command -v python3 &>/dev/null; then
PYTHON_CMD="python3"
elif command -v python &>/dev/null; then
PYTHON_CMD="python"
else
PYTHON_CMD=""
fi
# Check if Git is installed
if command -v git &>/dev/null; then
GIT_INSTALLED=1
else
GIT_INSTALLED=0
fi
install_tools() {
local install_python=$1
local install_git=$2
if command -v brew &>/dev/null; then
echo "Installing tools via Homebrew..."
[ "$install_python" = "1" ] && brew install python
[ "$install_git" = "1" ] && brew install git
else
echo "❌ Homebrew is not installed. Please install Homebrew (https://brew.sh) to automatically install dependencies."
read -p "Press Enter to exit..."
exit 1
fi
}
# Run immediately if both are present
if [ -n "$PYTHON_CMD" ] && [ "$GIT_INSTALLED" -eq 1 ]; then
$PYTHON_CMD GitRepoCloner.py
exit 0
fi
# CASE 1: Both missing
if [ -z "$PYTHON_CMD" ] && [ "$GIT_INSTALLED" -eq 0 ]; then
echo "❌ Python and Git are not installed."
read -p "Would you like to install both? (y/n): " choice
if [[ "$choice" =~ ^[Yy]$ ]]; then
install_tools 1 1
if command -v python3 &>/dev/null; then PYTHON_CMD="python3"; fi
else
exit 1
fi
# CASE 2: Python missing
elif [ -z "$PYTHON_CMD" ]; then
echo "❌ Python is not installed."
read -p "Would you like to install Python? (y/n): " choice
if [[ "$choice" =~ ^[Yy]$ ]]; then
install_tools 1 0
if command -v python3 &>/dev/null; then PYTHON_CMD="python3"; fi
else
exit 1
fi
# CASE 3: Git missing
elif [ "$GIT_INSTALLED" -eq 0 ]; then
echo "❌ Git is not installed."
read -p "Would you like to install Git? (y/n): " choice
if [[ "$choice" =~ ^[Yy]$ ]]; then
install_tools 0 1
else
exit 1
fi
fi
# Execute script
if [ -n "$PYTHON_CMD" ] && command -v git &>/dev/null; then
$PYTHON_CMD GitRepoCloner.py
else
echo "Please restart your terminal to apply the changes."
read -p "Press Enter to exit..."
fi