-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalive
More file actions
executable file
·61 lines (49 loc) · 1.23 KB
/
alive
File metadata and controls
executable file
·61 lines (49 loc) · 1.23 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
#!/bin/bash
# Configuration
# basepath of executable
basepath=$(cd `dirname $(readlink -f $0)`; pwd)
source "$basepath/lib/helpers.sh"
# Try to load variables from .env.local first
if [[ -f "$basepath/.env.local" ]]; then
source "$basepath/.env.local"
else
message "No .env.local found, using defaults"
fi
# can be sourced by other scripts
functions="$basepath/cli/functions/project.sh"
# Main script file: alive
command=$1 # First argument is the command
shift
# Parse flags
while [ "$1" != "" ]; do
case $1 in
--*)
flags="${1#--}"
shift
;;
-*)
flags="${1#-}"
shift
;;
*)
break
;;
esac
done
source_script() {
local script_name="$1"
local full_path="$basepath/cli/$script_name"
export script_name
if [ -f "$full_path" ]; then
source "$full_path" "$@"
else
error "Error: $script_name not found in cli directory. Available scripts: $(ls $basepath/cli/*.sh | sed 's/.*\///' | sed 's/.sh//')"
exit 1
fi
}
# if the flag is --help or -h: show help
if [ "$flags" = "help" ] || [ "$flags" = "h" ]; then
source_script "help.sh"
exit 0
fi
source_script "${command}.sh" "$@"