-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd.sh
executable file
·41 lines (36 loc) · 901 Bytes
/
cmd.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
#!/bin/bash
# Define your methods
genPlaygroundRPC() {
protoc \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
playground/hello.proto
}
genServiceRPC() {
protoc \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
service/service.proto
}
genRPC() {
protoc \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
$1
}
getPID() {
lsof -i :$1
}
# Check the argument passed and call the corresponding method
if [ "$1" = "genPlaygroundRPC" ]; then
genPlaygroundRPC
elif [ "$1" = "genServiceRPC" ]; then
genServiceRPC
elif [ "$1" = "genRPC" ]; then
genRPC $2
elif [ "$1" = "getPID" ]; then
getPID $2
else
echo "Usage: $0 [genPlaygroundRPC | genServiceRPC | genRPC <.proto>]"
exit 1
fi