-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbdp.sh
executable file
·78 lines (64 loc) · 1.84 KB
/
bdp.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
# FIXME Need to test this script and possibly change it so it spawns a new terminal when running the client/electron
# module so as not to block stdin/stdout
function usage {
echo "Blockchain Demo Platform (BDP) - simple cryptocurrency with electron"
echo "usage: bdp [--version] [--help] <command> [<args>]"
echo " "
echo "Available BDP commands:"
echo " update Update to the newest version"
echo " init Initialize the application (downloading dependencies, building etc"
echo " run Run the BDP client"
echo " visualize Run the electron module"
}
function display_version {
echo "BDP version 0.1.0"
}
function parse_args {
# positional args
args=()
# named args
while [ "$1" != "" ]; do
case "$1" in
-v | --version ) display_version; exit;;
-h | --help ) usage; exit;; # quit and show usage
* ) args+=("$1") # if no match, add it to the positional args
esac
shift # move to next kv pair
done
# restore positional args
set -- "${args[@]}"
if [[ -z "${args[0]}" ]]; then
echo "Need to specify the command!"
usage
exit;
fi
# set positionals to vars
command="${args[0]}"
case $command in
run ) run; exit;;
update ) update; exit;;
init ) init; exit;;
visualize ) visualize; exit;;
* ) echo "Unknown command!"
esac
}
function update {
echo "Updating..."
git pull origin master
echo "Done."
}
function init {
echo "Initializing..."
./gradlew build
npm install
echo "Done."
}
function visualize {
echo "Starting the electron module..."
npm start
}
function run {
echo "Starting the BDP client..."
./gradlew run
}
parse_args "$@"