-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·90 lines (77 loc) · 1.36 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
scriptFolder=$(dirname $(readlink -f $0))
getHelp() {
cat <<HELP
Commands related to this script
USAGE:
$(basename $0) SUBCOMMAND
$(basename $0) -h | --help
FLAGS:
-h Print help informations.
--help Print help informations.
SUBCOMMANDS:
build Build the website
addImg Add element to an existing website
install Install the environment
BUILD SUBCOMMAND HELP:
--auth Add an authentification to the site.
-o <directory> Sepcify the output folder.
--output=<directory> Sepcify the output folder.
HELP
return 1
}
main() {
while getopts ':ho:-:' option; do
case $option in
-)
case ${OPTARG} in
help)
getHelp
exit 0
;;
*)
echo "Invalid option --${OPTARG}\n">&2
getHelp>&2
exit 1
;;
esac;;
h)
getHelp
exit 0
;;
\?)
echo "Invalid option -$option \n" >&2
getHelp >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
# Remove main command from the args list
subcommand="${1:-}"
if [ -z ${subcommand} ]; then
echo "Please enter a subcommand!"
getHelp
return 0
fi
shift
case "${subcommand}" in
install)
${scriptFolder}/install.sh
exit 0
;;
build)
${scriptFolder}/build.sh ${@}
exit 0
;;
addImg)
${scriptFolder}/addImg.sh ${@}
exit 0
;;
*)
echo "Invalid subcommand: ${subcommand}!"
getHelp
;;
esac
}
main ${@}