-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·75 lines (62 loc) · 1.6 KB
/
run.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
#!/bin/zsh
# ##############################################################################
do_init() {
# https://grpc.io/docs/protoc-installation/
brew install protobuf
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
}
do_build() {
go build -o bin/stacker
}
do_cover() {
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
}
do_test() {
watch --color go test ./tests/...
}
do_vet() {
watch --color go vet
}
do_fmt() {
watch gofmt -d ***/*.go
}
do_proto(){
protoc --go_out=. \
--go_opt=paths=source_relative \
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
grpc/stacker.proto
}
usage() {
echo "Usage statment"
format="%4s %-4s : %s\n"
printf "${format}" "Flag" "Arg" "Description"
printf "${format}" "----" "----" "----"
printf "${format}" "b" "----" "Build application"
printf "${format}" "i" "----" "Install/initialize dependencies"
printf "${format}" "p" "----" "Build proto files"
printf "${format}" "t" "----" "Run tests in a watch"
printf "${format}" "v" "----" "Run vet in a watch"
printf "${format}" "x" "msg" "Prints out a message"
}
# ##############################################################################
# Behavior for no parameters
if [ $# -eq 0 ]; then
usage
exit 1
fi
while getopts bicfptvx: opt ; do
case "${opt}" in
b) do_build ;;
c) do_cover ;;
i) do_init ;;
p) do_proto ;;
t) do_test ;;
v) do_vet ;;
f) do_fmt ;;
x) echo "${OPTARG}" ;;
*) usage ;;
esac
done