This repository was archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility
87 lines (73 loc) · 1.68 KB
/
utility
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
#! /bin/bash
###############################
# Easy Coding 2 Utility File #
###############################
if [ $_UTILITY_ ]; then
print w "utility already imported"
else
_UTILITY_=1
##########################################
# TODO: Code begin
# Print text on terminal
function print() {
# $1: type
# $2: text
TYPE=$1
shift
case $TYPE in
[iI]|[iI][nN][fF][oO]) echo -e "\e[32m$@\e[0m";; # info
[wW]|[wW][aA][rR][nN][iI][nN][gG]) echo -e "\e[33m$@\e[0m";; # warning
[eE]|[eE][rR][rR][oO][rR]) echo -e "\e[31m$@\e[0m";; # error
esac
unset TYPE
}
# load config
function loadCfg() {
# $1: project name
import "config/$1"
}
# execute a cmd
function execute() {
# $1: cmd
# $2: parameters (optinal)
# $3: parameters (optinal)
# $n: parameters (optinal)
source $SCRIPT_DIR/cmd/$@ ""
}
# load cmd list
function loadCmdList() {
# $1: Script base dir
# $2: Parameter to receive the result
unset $2
i="0"
for file in $1/cmd/*; do
eval $2[$i]="${file#$1/cmd/}"
i=$((i + 1))
done
# clean up
unset file
unset i
}
# load config list
function loadCfgList() {
# $1: Script base dir
# $2: Parameter to receive the result
unset $2
i="0"
for file in $1/config/*; do
eval $2[$i]="${file#$1/config/}"
i=$((i + 1))
done
# clean up
unset file
unset i
}
# help
function help() {
print w "ec2 [PROJECT] [CMD1] <PARAMETER1> <PARAMETER2>, <CMD2> <PARAMETER1> <PARAMETER2>..."
print w "Example:"
print w " ec2 scribe5 clone, make -j4, shutdown"
}
# TODO: Code end
##########################################
fi