Skip to content

Commit

Permalink
Merge pull request #25 from EmbarkStudios/rasviitanen/btree-map
Browse files Browse the repository at this point in the history
Add support for BTreeMap output
  • Loading branch information
bwestlin authored Aug 5, 2024
2 parents 6572f26 + 3d8666e commit 5756968
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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#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.
Expand Down
10 changes: 9 additions & 1 deletion proto-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ 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,

/// Disable comments based on proto path. Passing '.' disables all comments.
#[clap(short, long)]
disable_comments: Vec<String>,

/// Output maps as `BTreeMap` instead of `HashMap`. Passing '.' makes all maps `BTreeMap`.
#[clap(short, long = "btree-map")]
btree_maps: Vec<String>,

/// Type attributes to add.
#[clap(long = "type-attribute", value_parser=KvValueParser)]
type_attributes: Vec<(String, String)>,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -241,6 +247,7 @@ message TestMessage {
disable_comments: vec![],
type_attributes: vec![],
enum_attributes: vec![],
btree_maps: vec![],
client_attributes: vec![],
server_attributes: vec![],
};
Expand Down Expand Up @@ -389,6 +396,7 @@ message NestedTransitiveMsg {
disable_comments: vec![],
type_attributes: vec![],
enum_attributes: vec![],
btree_maps: vec![],
client_attributes: vec![],
server_attributes: vec![],
};
Expand Down

0 comments on commit 5756968

Please sign in to comment.