RustySamovar/gen_ids.sh
2021-10-03 00:18:53 +05:00

28 lines
521 B
Bash
Executable File

#!/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 "}";