Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created November 4, 2020 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlbinoDrought/78ee4a63cf3035308da7ed05dc432722 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/78ee4a63cf3035308da7ed05dc432722 to your computer and use it in GitHub Desktop.
Dirty conversion of protobuf_config.py from https://github.com/mildsunrise/protobuf-inspector to .proto
Replace
"([^"]+)": ?\{
With
message $1 {
Replace
},
With
}
Replace
((\d+): ?\("([^"]+)", "([^"]+)"[^\n]+)
With
$3 $4 = $2;
syntax = "proto3";
package stuff;
message Packet {
uint32 timestamp = 1;
string username = 2;
packed varint stuff = 7;
float other_stuff = 10;
item available_items = 14;
}
message Item {
string name = 1;
varint price = 2;
}
types = {
"root": {
1: ("uint32", "timestamp"),
2: ("string", "username"),
7: ("packed varint", "stuff"),
10: ("float", "other_stuff"),
14: ("item", "available_items"),
},
"item": {
1: ("string", "name"),
2: ("varint", "price"),
},
}
types = {
message root {
uint32 timestamp = 1;
string username = 2;
packed varint stuff = 7;
float other_stuff = 10;
item available_items = 14;
}
message item {
string name = 1;
varint price = 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment