-
Notifications
You must be signed in to change notification settings - Fork 0
/
flash_cb
executable file
·69 lines (54 loc) · 1.06 KB
/
flash_cb
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
#!/bin/sh
# Text STYLE variables
BOLD="\033[1m"
RED='\033[38;5;9m'
GREEN='\033[38;5;2m'
ORANGE_RED="\033[38;5;202m"
C_DODGERBLUE2="\033[38;5;27m"
VERSION='flashCB v0.0.1'
die() {
echo "${0##*/}: error: $*" >&2
exit 1
}
_echo_color() {
printf "${1}%s${NC}\n" "$2"
}
_printf_color() {
printf "${1}%s" "$2"
_echo_color "${NC}" ""
}
usage() {
echo "Usage: flash_cb [board] [type]
This does something useful!
Options:
-v show version
-h help"
exit 0
}
flash_image (){
_printf_color "${BOLD}" "------> flash start"
echo "flash" $1 with $2
}
###############################################################################
#
#
#
main () {
local board=""
local type=""
while getopts 'vhb:t:' flag; do
case ${flag} in
v) echo "${VERSION}" ;;
h) usage ;;
b) board="${OPTARG}" ;;
t) type="${OPTARG}" ;;
*) die "invalid option found" ;;
esac
done
if [ -z $board ] || [ -z $type ]; then
usage
else
flash_image ${board} ${type}
fi
}
main "$@"