Allow setting enum proto values from the command line.

This commit is contained in:
David Given
2021-09-19 22:59:47 +02:00
parent 7186b25a69
commit 07c7b22669

View File

@@ -156,6 +156,17 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
break;
}
case google::protobuf::FieldDescriptor::TYPE_ENUM:
{
const auto* enumfield = field->enum_type();
const auto* enumvalue = enumfield->FindValueByName(value);
if (!enumvalue)
Error() << fmt::format("unrecognised enum value '{}'", value);
reflection->SetEnum(message, field, enumvalue);
break;
}
case google::protobuf::FieldDescriptor::TYPE_MESSAGE:
if (field->message_type() == RangeProto::descriptor())
{