-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteve.sh
executable file
·59 lines (49 loc) · 1.01 KB
/
steve.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
#!/bin/bash
set -e
config() {
CLI_DIR="cli"
AVAILABLE_COMMANDS=( $( ls "${CLI_DIR}" ) )
COMMAND=""
}
display_help() {
echo "Steve Utils CLI"
echo "Set of Steve automation and debugging commands"
echo
echo "Run one of the following commands:"
echo " ${AVAILABLE_COMMANDS[@]}"
echo
echo "All commands are configurable via environment variables."
}
parse_args() {
while [[ "${#}" -gt 0 ]]; do
case "${1}" in
-h|--help) display_help; exit 0;;
*) COMMAND="${1}"; shift 1;;
esac
done
}
command_exists() {
local command="${1}"
local result="$( find "${CLI_DIR}" -name "${command}" )"
if [[ result == "" ]]; then
echo "false"
fi
echo "true"
}
run_command() {
local cmd="${1}"
shift 1
"./${CLI_DIR}/${cmd}/run.sh" "${@}"
}
main() {
config
parse_args "${@}"
local exists="$( command_exists "${COMMAND}" )"
if [[ "${exists}" == "false" ]]; then
echo "Command ${COMMAND} not found"
display_help
exit 1
fi
run_command "${@}"
}
main "${@}"