UNPKG

813 Bapplication/x-shView Raw
1#!/usr/bin/env bash
2
3set -eo pipefail
4
5function echo_name () {
6 cat <<_EOF_
7/******************************************************************
8 * Proto File: $1
9 ******************************************************************/
10_EOF_
11}
12
13function strip_header () {
14 sed -r '/^(syntax|package|import|option)/s/.*//'
15}
16
17function strip_package () {
18 # (base.
19 # (stream event.
20 sed -r 's/ \(\w+\./ \(/g' \
21 | sed -r 's/ \(stream \w+\./ \(stream /'
22}
23
24function main () {
25 cat <<'_EOF_'
26syntax = "proto3";
27import "google/protobuf/wrappers.proto";
28package 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
43main