forked from digitalocean/prometheus-client-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto
executable file
·82 lines (64 loc) · 1.76 KB
/
auto
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
#!/usr/bin/env bash
########################################################################################################################
# Meta
########################################################################################################################
# Propagate environment variables
if [[ "$AUTO_DEBUG" == "1" ]]; then
set -x
export AUTO_DEBUG=1
fi
export PROJECT_ROOT=$(pushd $(dirname $0) > /dev/null; echo $PWD; popd > /dev/null)
export DOCKER_IMAGE
export CI=${CI:=0}
export CC=/usr/bin/gcc
PROGRAM_NAME="$(basename $0)"
usage(){
cat <<EOF
$PROGRAM_NAME [command [options...]]
Provide developer workflow automation
$PROGRAM_NAME command -h for help
COMMANDS
$(commands)
ENVIRONMENT
AUTO_DEBUG Set to 1 to enable and 0 to disable
EOF
}
########################################################################################################################
# End Meta
########################################################################################################################
declare -i DEV=${DEV:=1} && export DEV
declare lib="$(dirname ${BASH_SOURCE[0]})/autolib"
source "${lib}/autolib.sh"
commands(){
while read cmd; do
printf "${cmd} - "
source "${lib}/cmd/${cmd}"
echo "$short"
done < <(ls -1 "${lib}/cmd")
}
main(){
if [[ "$PROJECT_ROOT" != "$PWD" ]]; then
echo "You must execute auto within the PROJECT_ROOT $PROJECT_ROOT"
exit 1
fi
if (($# < 1)); then
usage
exit 1
fi
local cmd=$1
case "$cmd" in
( -h | --help | help ) {
usage
exit 0
} ;;
( build | dev | test | package | docs | clean | smoke | format ) {
shift
exec "${lib}/cmd/${cmd}" $@ || exit $?
} ;;
( * ) {
usage
exit 1
} ;;
esac
}
[[ $BASH_SOURCE == $0 ]] && main $@