-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·53 lines (42 loc) · 792 Bytes
/
dev.sh
File metadata and controls
executable file
·53 lines (42 loc) · 792 Bytes
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
CWD=$(pwd)
SCRIPTS_DIR="$CWD/scripts"
chmod +x $SCRIPTS_DIR/*.sh
chmod +x $CWD/*.sh
source $CWD/config.sh
__start_env() {
if [ -f ".venv/bin/activate" ]; then
source .venv/bin/activate
fi
}
__close_env() {
if [ -f ".venv/bin/activate" ]; then
if [ -n "$VIRTUAL_ENV" ]; then
deactivate
fi
fi
}
__guide() {
$SCRIPTS_DIR/help.sh $SCRIPTS_DIR $@
}
dev() {
if [ $# -eq 0 ]; then
__guide $@
return 0
fi
COMMAND=$1
shift
trap __close_env EXIT
if [ ! -f "$SCRIPTS_DIR/$COMMAND.sh" ]; then
echo "Unknown command: $COMMAND\n"
__guide $@
return 1
fi
COMMAND_HELP=$(echo "$COMMAND" | grep "^help$")
if [ -n "$COMMAND_HELP" ]; then
__guide $@
return $?
fi
__start_env
"$SCRIPTS_DIR/$COMMAND.sh" "$@"
return $?
}