Skip to content

Commit

Permalink
feat: add touch_all yml config
Browse files Browse the repository at this point in the history
  • Loading branch information
Millione committed Nov 27, 2023
1 parent 72e2487 commit 3cf33fb
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 82 deletions.
201 changes: 122 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/volo-gen/volo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ entries:
proto:
protocol: protobuf
filename: proto_gen.rs
touch_all: false
idls:
- source: local
path: ../proto/hello.proto
Expand All @@ -18,6 +19,7 @@ entries:
thrift:
protocol: thrift
filename: thrift_gen.rs
touch_all: false
idls:
- source: local
path: ../thrift_idl/hello.thrift
Expand Down
2 changes: 1 addition & 1 deletion volo-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-build"
version = "0.8.4"
version = "0.8.5"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
11 changes: 10 additions & 1 deletion volo-build/src/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ impl InnerBuilder {
}
}

pub fn ignore_unused(self, ignore_unused: bool) -> Self {
match self {
InnerBuilder::Protobuf(inner) => {
InnerBuilder::Protobuf(inner.ignore_unused(ignore_unused))
}
InnerBuilder::Thrift(inner) => InnerBuilder::Thrift(inner.ignore_unused(ignore_unused)),
}
}

pub fn keep_unknown_fields(self, keep: impl IntoIterator<Item = PathBuf>) -> Self {
match self {
InnerBuilder::Protobuf(inner) => {
Expand Down Expand Up @@ -144,7 +153,7 @@ impl ConfigBuilder {
}
}

builder.write()?;
builder.ignore_unused(!entry.touch_all).write()?;

Ok(())
})?;
Expand Down
2 changes: 2 additions & 0 deletions volo-build/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub struct Entry {
pub filename: PathBuf,

pub idls: Vec<Idl>,
#[serde(default)]
pub touch_all: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion volo-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-cli"
version = "0.8.2"
version = "0.8.3"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
1 change: 1 addition & 0 deletions volo-cli/src/idl/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl CliCommand for Add {
protocol: new_idl.protocol(),
filename: PathBuf::from(&self.filename),
idls: vec![new_idl],
touch_all: false,
},
);
}
Expand Down
1 change: 1 addition & 0 deletions volo-cli/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ impl CliCommand for Init {
protocol: idl.protocol(),
filename: PathBuf::from(DEFAULT_FILENAME),
idls: vec![idl.clone()],
touch_all: false,
};
if self.is_grpc_project() {
self.copy_grpc_template(entry.clone())?;
Expand Down

0 comments on commit 3cf33fb

Please sign in to comment.