From fc1e3f72298fa0952d7f0ce39b4fd5d6cb62c8f4 Mon Sep 17 00:00:00 2001 From: Rasmus Viitanen Date: Thu, 25 Apr 2024 09:04:18 +0200 Subject: [PATCH 1/2] Add support for enum attributes --- proto-gen/src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/proto-gen/src/main.rs b/proto-gen/src/main.rs index 16aa1f5..c87bd3e 100644 --- a/proto-gen/src/main.rs +++ b/proto-gen/src/main.rs @@ -61,6 +61,10 @@ struct TonicOpts { #[clap(long = "type-attribute", value_parser=KvValueParser)] type_attributes: Vec<(String, String)>, + /// Enum attributes to add. + #[clap(long = "enum-attribute", value_parser=KvValueParser)] + enum_attributes: Vec<(String, String)>, + /// Client mod attributes to add. #[clap(long = "client-attribute", value_parser=KvValueParser)] client_attributes: Vec<(String, String)>, @@ -125,6 +129,10 @@ fn run_with_opts(opts: Opts) -> Result<(), i32> { bldr = bldr.type_attribute(k, v); } + for (k, v) in opts.tonic.enum_attributes { + bldr = bldr.enum_attribute(k, v); + } + for (k, v) in opts.tonic.client_attributes { bldr = bldr.client_mod_attribute(k, v); } @@ -232,6 +240,7 @@ message TestMessage { generate_transport: false, disable_comments: vec![], type_attributes: vec![], + enum_attributes: vec![], client_attributes: vec![], server_attributes: vec![], }; @@ -379,6 +388,7 @@ message NestedTransitiveMsg { generate_transport: false, disable_comments: vec![], type_attributes: vec![], + enum_attributes: vec![], client_attributes: vec![], server_attributes: vec![], }; From f1946dc10e804049fba715af079801c79d62a278 Mon Sep 17 00:00:00 2001 From: Rasmus Viitanen Date: Thu, 25 Apr 2024 09:17:17 +0200 Subject: [PATCH 2/2] Add changelog entry --- proto-gen/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proto-gen/CHANGELOG.md b/proto-gen/CHANGELOG.md index a21f3c4..6f79b44 100644 --- a/proto-gen/CHANGELOG.md +++ b/proto-gen/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Added +- [PR#23](https://github.com/EmbarkStudios/proto-gen/pull/23) Added `--enum-attribute` option to set enum attributes. + ## [0.2.5] - 2024-03-13 ### Fixed - [PR#22](https://github.com/EmbarkStudios/proto-gen/pull/22) Various fixes for the `--prepend-header` option and some cases for escaped doc-tests.