diff --git a/proto-gen/CHANGELOG.md b/proto-gen/CHANGELOG.md index 86721e7..173b1ce 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#24](https://github.com/EmbarkStudios/proto-gen/pull/24) Added `--btree-map` option to output BTreeMaps instead of HashMaps. + ## [0.2.6] - 2024-04-25 ### Added - [PR#23](https://github.com/EmbarkStudios/proto-gen/pull/23) Added `--enum-attribute` option to set enum attributes. diff --git a/proto-gen/src/main.rs b/proto-gen/src/main.rs index c87bd3e..08cdb9c 100644 --- a/proto-gen/src/main.rs +++ b/proto-gen/src/main.rs @@ -49,7 +49,7 @@ struct TonicOpts { #[clap(short = 'c', long)] build_client: bool, - /// Whether to generate the ::connect and similar functions for tonic. + /// Whether to generate the `::connect` and similar functions for tonic. #[clap(long)] generate_transport: bool, @@ -57,6 +57,10 @@ struct TonicOpts { #[clap(short, long)] disable_comments: Vec, + /// Output maps as `BTreeMap` instead of `HashMap`. Passing '.' makes all maps `BTreeMap`. + #[clap(short, long = "btree-map")] + btree_maps: Vec, + /// Type attributes to add. #[clap(long = "type-attribute", value_parser=KvValueParser)] type_attributes: Vec<(String, String)>, @@ -144,6 +148,8 @@ fn run_with_opts(opts: Opts) -> Result<(), i32> { let mut config = prost_build::Config::new(); config.disable_comments(opts.tonic.disable_comments); + config.btree_map(opts.tonic.btree_maps); + let (ws, commit) = match opts.routine { Routine::Validate { workspace } => (workspace, false), Routine::Generate { workspace } => (workspace, true), @@ -241,6 +247,7 @@ message TestMessage { disable_comments: vec![], type_attributes: vec![], enum_attributes: vec![], + btree_maps: vec![], client_attributes: vec![], server_attributes: vec![], }; @@ -389,6 +396,7 @@ message NestedTransitiveMsg { disable_comments: vec![], type_attributes: vec![], enum_attributes: vec![], + btree_maps: vec![], client_attributes: vec![], server_attributes: vec![], };