-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc
executable file
·52 lines (42 loc) · 1.45 KB
/
doc
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
#!/bin/bash
# Get the directory where the code is located (not where the script is symlinked)
SCRIPT_DIR="$( cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" &> /dev/null && pwd )"
# Quiet mode for pip
export PIP_QUIET=1
# Function to check dependencies silently
check_dependency() {
if ! command -v "$1" &>/dev/null; then
echo "❌ $2 is required but not found"
exit 1
fi
}
# Check dependencies silently
check_dependency "python3" "Python 3"
check_dependency "pip3" "pip3"
python3 -c "import venv" &>/dev/null || { echo "❌ Python venv module is required but not found"; exit 1; }
# Create virtual environment if it doesn't exist (silently)
VENV_DIR="$SCRIPT_DIR/.venv"
if [ ! -d "$VENV_DIR" ]; then
python3 -m venv "$VENV_DIR" &>/dev/null
fi
# Activate virtual environment (silently)
source "$VENV_DIR/bin/activate" &>/dev/null
# Install dependencies if requirements.txt exists and packages aren't installed (silently)
REQUIREMENTS="$SCRIPT_DIR/requirements.txt"
if [ -f "$REQUIREMENTS" ]; then
if ! pip freeze | grep -q "markdown=="; then
pip install -r "$REQUIREMENTS" &>/dev/null
fi
fi
# Install the package in development mode if not already installed
if ! pip show wasdoing &>/dev/null; then
pip install -e "$SCRIPT_DIR" &>/dev/null
fi
# Run the module
if [ $# -eq 0 ]; then
python3 -m wasdoing --help
else
python3 -m wasdoing "$@"
fi
# Deactivate virtual environment (silently)
deactivate &>/dev/null