-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path42MapGenerator.sh
114 lines (103 loc) · 3.35 KB
/
42MapGenerator.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
#####################################################
# _ _ ____ __ __ ____ #
# | || ||___ \| \/ | __ _ _ __ / ___| ___ _ __ #
# | || |_ __) | |\/| |/ _` | '_ \| | _ / _ \ '_ \ #
# |__ _/ __/| | | | (_| | |_) | |_| | __/ | | | #
# |_||_____|_| |_|\__,_| .__/ \____|\___|_| |_| #
# jgigault @ student.42.fr |_| 06 51 15 98 82 #
#####################################################
OPT_NO_UPDATE=0
OPT_NO_COLOR=0
OPT_NO_TIMEOUT=0
OPT_WITH_ENTRYPATH=0
i=1
while (( i <= $# ))
do
case "${!i}" in
"--no-update") OPT_NO_UPDATE=1 ;;
"--no-color") OPT_NO_COLOR=1 ;;
"--no-timeout") OPT_NO_TIMEOUT=1 ;;
"--with-entrypath")
OPT_WITH_ENTRYPATH=1
(( i += 1 ))
GLOBAL_ENTRYPATH="${!i}"
;;
esac
(( i += 1 ))
done
function mapgen_install_dir
{
local SOURCE="${BASH_SOURCE[0]}"
local DIR
while [ -h "${SOURCE}" ]
do
DIR="$(cd -P "$(dirname "${SOURCE}")" && pwd)"
SOURCE="$(readlink "${SOURCE}")"
[[ "${SOURCE}" != /* ]] && SOURCE="${DIR}/${SOURCE}"
done
printf "%s" "$(cd -P "$(dirname "${SOURCE}")" && pwd)"
}
if [ "${OPT_WITH_ENTRYPATH}" == "0" -o "${GLOBAL_ENTRYPATH}" == "" ]
then
GLOBAL_ENTRYPATH=$(pwd)
fi
GLOBAL_INSTALLDIR=$(mapgen_install_dir)
cd "${GLOBAL_INSTALLDIR}"
GLOBAL_VERSION=2
GLOBAL_DISK_USAGE=
GLOBAL_LOCALBRANCH=$(git branch | awk '$0 ~ /^\*/ {print $2; exit}')
MAPGENERATOR_SH=1
RETURNPATH=$(pwd | sed 's/ /\ /g')
GLOBAL_CVERSION=$(git log --oneline 2>/dev/null | awk 'END {printf NR}' | sed 's/ //g')
if [ -z "${GLOBAL_CVERSION}" ]; then GLOBAL_CVERSION="???"; fi
source includes/maps.sh
source includes/data_providers.sh
source includes/utils.sh
source includes/display_menu.sh
source includes/display_header.sh
source includes/display_center.sh
source includes/display_section.sh
source includes/display_error.sh
source includes/display_success.sh
source includes/display_right.sh
source includes/display_leftandright.sh
source includes/display_spinner.sh
source includes/generate_map.sh
source includes/download_map.sh
source includes/google_api.sh
source includes/ign.sh
source includes/noaa.sh
source includes/mgds.sh
source includes/usgs.sh
source includes/config.sh
source includes/credits.sh
source includes/update.sh
source includes/signals.sh
function main
{
local RETURNFUNCTION="main" DATA_PROVIDER_ID="" MAPS_ID="" MAPS_FORMAT="" MY_EXPORT_PATH=$(utils_get_config "export_path")
if [ "${MY_EXPORT_PATH}" == "" ]
then
config_path
else
display_header
display_section
display_menu\
"" "Select a data provider:"\
main_ign "${DATA_PROVIDERS[$(utils_data_provider_id "IGN")]}"\
main_noaa "${DATA_PROVIDERS[$(utils_data_provider_id "NOAA")]}"\
main_mgds "${DATA_PROVIDERS[$(utils_data_provider_id "MGDS")]}"\
main_usgs "${DATA_PROVIDERS[$(utils_data_provider_id "USGS")]}"\
"_"\
"config_path" "Change export directory"\
"_"\
"utils_option_set OPT_NO_TIMEOUT" "$(if [ "$OPT_NO_TIMEOUT" == 0 ]; then echo "Disable timeout (--no-timeout)"; else echo "Enable timeout"; fi)"\
"utils_option_set OPT_NO_COLOR" "$(if [ "$OPT_NO_COLOR" == 0 ]; then echo "Disable color (--no-color)"; else echo "Enable color"; fi)"\
"_"\
display_credits "CREDITS"\
"open https://github.com/jgigault/42MapGenerator/issues/new" "REPORT A BUG"\
utils_exit "EXIT"
fi
}
utils_start