Skip to content

Commit a7b7aa6

Browse files
committed
merge proto files (#46)
1 parent 11f5161 commit a7b7aa6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

scripts/merge-proto.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
function echo_name () {
6+
cat <<_EOF_
7+
/******************************************************************
8+
* Proto File: $1
9+
******************************************************************/
10+
_EOF_
11+
}
12+
13+
function strip_header () {
14+
sed -r '/^(syntax|package|import)/s/.*//'
15+
}
16+
17+
function strip_package () {
18+
# (base.
19+
# (stream event.
20+
sed -r 's/ \(\w+\./ \(/g' \
21+
| sed -r 's/ \(stream \w+\./ \(stream /'
22+
}
23+
24+
function main () {
25+
cat <<'_EOF_'
26+
syntax = "proto3";
27+
import "google/protobuf/wrappers.proto";
28+
package wechaty.puppet;
29+
_EOF_
30+
31+
for file in proto/wechaty/puppet/*.proto; do
32+
echo_name "$file"
33+
cat "$file" | strip_header
34+
done
35+
36+
file='proto/wechaty/puppet.proto'
37+
echo_name "$file"
38+
cat "$file" \
39+
| strip_header \
40+
| strip_package
41+
}
42+
43+
main

0 commit comments

Comments
 (0)