RustySamovar/gen_ids.sh

28 lines
521 B
Bash
Raw Normal View History

2021-10-02 19:18:53 +00:00
#!/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 "}";