-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·72 lines (61 loc) · 1.89 KB
/
run.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
#!/bin/bash
set -e
# Function to handle errors
handle_error() {
echo "Error: $1" >&2
exit 1
}
# Check if Poetry is already installed
if command -v poetry &> /dev/null; then
echo "Poetry is already installed."
poetry --version
else
# User confirmation for installation
read -p "Poetry is not installed. Do you want to install it? (Y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Operation cancelled."
exit 0
fi
# Install Poetry
echo "Installing Poetry..."
curl -sSL https://install.python-poetry.org | python3 - || handle_error "Failed to install Poetry"
# Add Poetry to PATH
echo "Adding Poetry to PATH..."
export PATH="$HOME/.local/bin:$PATH"
# Verify installation
echo "Verifying Poetry installation..."
poetry --version || handle_error "Poetry installation failed"
fi
# Check if dependencies are installed
if poetry check --no-interaction &> /dev/null; then
echo "Dependencies are up to date."
read -p "Do you want to run 'poetry install' anyway? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Running 'poetry install'..."
poetry install || handle_error "Failed to run 'poetry install'"
fi
else
echo "Dependencies are not installed or out of date. Running 'poetry install'..."
poetry install || handle_error "Failed to run 'poetry install'"
fi
# Run a Poetry command
echo "Choose which command to run:"
echo "1) app (finance-crew-app)"
echo "2) cli (finance-crew-cli)"
read -p "Enter your choice (1 or 2): " choice
case $choice in
1)
command="finance-crew-app"
;;
2)
command="finance-crew-cli"
;;
*)
handle_error "Invalid choice. Please enter 1 or 2."
;;
esac
echo "Running: poetry run $command"
poetry run $command || handle_error "Failed to run Poetry command"
echo "Operation completed successfully."