Autogenerate PacketId enum

This commit is contained in:
Nobody 2021-10-03 00:18:53 +05:00
parent 4b9fda1f84
commit 227a5ad7c8
2 changed files with 34 additions and 0 deletions

7
.gitignore vendored
View File

@ -14,3 +14,10 @@ Cargo.lock
# keys # keys
/keys/ /keys/
# Vim temp files
.*.swp
.*.swo
# Autogenerated files
/gen/

27
gen_ids.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
#echo "#[macro_use]";
#echo "extern crate num_derive;";
#echo "";
echo "// Autogenerated file, do not edit!"
echo "";
echo "#[repr(u16)]";
echo "#[derive(FromPrimitive, ToPrimitive)]";
echo "#[derive(Debug, PartialEq, Eq, Clone, Hash)]";
echo "pub enum PacketId {";
for f in protobuf/*; do
CMD_ID=`cat $f | grep CMD_ID | cut -d'=' -f2 | tr -d ' ;\015'`;
if [ "x${CMD_ID}" != "x" ]; then
NAME=`echo $f | cut -d'/' -f2 | cut -d'.' -f1`;
echo " ${NAME} = ${CMD_ID},"
fi
done
echo "}";