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|option)/s/.*//'
|
15 | }
|
16 |
|
17 | function strip_package () {
|
18 |
|
19 |
|
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;
|
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
|