-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize
executable file
·92 lines (66 loc) · 2.04 KB
/
customize
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
#!/usr/bin/env bash
# REQUIRED DEPENDENCIES
# -------------------------------------------------------------------------------------------------
#
# To run this script, you must have the following tools installed:
# - bash 4
# Entrypoint
# -------------------------------------------------------------------------------------------------
function main {
validate_requirements
customize
selfdestruct
}
# Validate
# -------------------------------------------------------------------------------------------------
function validate_requirements {
validate_dependencies
}
function validate_dependencies {
validate_bash_dependency
}
function validate_bash_dependency {
major_version="$(bash --version | head -1 | cut -d ' ' -f 4 | cut -d '.' -f 1)"
min_major_version="4"
if [ "${major_version}" -lt "${min_major_version}" ]; then
throw_error "Your bash major version must be ${min_major_version} or greater"
fi
}
# Customize
# -------------------------------------------------------------------------------------------------
function customize {
}
# Selfdestruct
# -------------------------------------------------------------------------------------------------
function selfdestruct {
}
# Helpers
# -------------------------------------------------------------------------------------------------
function log_title {
message=$1
bold=$(tput bold)
reset=$(tput sgr0)
magenta=$(tput setaf 5)
number_of_columns="$(($(tput cols)-27))"
separator_spaces=$(printf "%${number_of_columns}s")
echo
echo "${bold}${magenta}${message}${reset}"
echo ${separator_spaces// /-}
}
function log_error {
message=$1
bold=$(tput bold)
reset=$(tput sgr0)
red=$(tput setaf 1)
echo "${bold}${red}Error:${reset}"
echo "${red} ${message}${reset}"
}
function start_spinner_in_category {
category=$1
message=$2
full_message=" \x1B[36m\r➤\e[1m ${category}:\x1B[0m ${message}"
start_spinner "${full_message}"
}
# Execute
# -------------------------------------------------------------------------------------------------
main $@