Skip to content

Commit

Permalink
Merge pull request #23 from EmbarkStudios/rasviitanen/enum-attributes
Browse files Browse the repository at this point in the history
Add support for enum attributes
  • Loading branch information
rasviitanen authored Apr 25, 2024
2 parents 30f30b4 + f1946dc commit 3176066
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions proto-gen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [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.
Expand Down
10 changes: 10 additions & 0 deletions proto-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>,
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -232,6 +240,7 @@ message TestMessage {
generate_transport: false,
disable_comments: vec![],
type_attributes: vec![],
enum_attributes: vec![],
client_attributes: vec![],
server_attributes: vec![],
};
Expand Down Expand Up @@ -379,6 +388,7 @@ message NestedTransitiveMsg {
generate_transport: false,
disable_comments: vec![],
type_attributes: vec![],
enum_attributes: vec![],
client_attributes: vec![],
server_attributes: vec![],
};
Expand Down

0 comments on commit 3176066

Please sign in to comment.