Skip to content

Commit

Permalink
Generate value as bool (#209)
Browse files Browse the repository at this point in the history
* Generate value as bool

This will generate publish=false as an actual toml bool, instead of a string value

* Update changelog
  • Loading branch information
hatchan authored May 16, 2024
1 parent 7cd4fc6 commit 38db22c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## unreleased

- Add ability to add `publish` to the generated Cargo.toml file (#208)
- Fix generating publish value as a toml bool (#209)

## [3.0.0] - 2023-04-28

Expand Down
9 changes: 8 additions & 1 deletion fp-bindgen/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub enum RustPluginConfigValue {
String(String),
Vec(Vec<String>),
Workspace,
Bool(bool),
}

impl From<&str> for RustPluginConfigValue {
Expand All @@ -123,6 +124,12 @@ impl From<Vec<String>> for RustPluginConfigValue {
}
}

impl From<bool> for RustPluginConfigValue {
fn from(value: bool) -> Self {
Self::Bool(value)
}
}

pub struct RustPluginConfigBuilder {
config: RustPluginConfig,
}
Expand Down Expand Up @@ -184,7 +191,7 @@ impl RustPluginConfigBuilder {
}

pub fn publish(mut self, value: bool) -> Self {
self.config.publish = Some(RustPluginConfigValue::String(value.to_string()));
self.config.publish = Some(value.into());
self
}

Expand Down
1 change: 1 addition & 0 deletions fp-bindgen/src/generators/rust_plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ fn format_cargo_key(key: &str, value: Option<RustPluginConfigValue>) -> String {
inline.insert("workspace", true.into());
toml_edit::value(inline)
}
RustPluginConfigValue::Bool(value) => toml_edit::value(value),
};

let mut doc = toml_edit::Document::new();
Expand Down

0 comments on commit 38db22c

Please sign in to comment.