Skip to content

Commit

Permalink
Allow adding published to the generated Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
hatchan committed May 16, 2024
1 parent 7e60cbf commit 4b18d22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions fp-bindgen/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ pub struct RustPluginConfig {

/// The license of the generated crate.
pub license: Option<RustPluginConfigValue>,

/// Whether the crate is marked as published or not (note: this should
/// the string value "true" or "false")
pub published: Option<RustPluginConfigValue>,
}

impl RustPluginConfig {
Expand All @@ -81,6 +85,7 @@ impl RustPluginConfig {
description: None,
readme: None,
license: None,
published: None,
},
}
}
Expand Down Expand Up @@ -178,6 +183,11 @@ impl RustPluginConfigBuilder {
self
}

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

pub fn dependency(mut self, name: impl Into<String>, dependency: CargoDependency) -> Self {
self.config.dependencies.insert(name.into(), dependency);
self
Expand Down
3 changes: 2 additions & 1 deletion fp-bindgen/src/generators/rust_plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn generate_cargo_file(
format!(
"[package]
{}{}{}edition = \"2018\"
{}{}{}
{}{}{}{}
[dependencies]
{}
",
Expand All @@ -112,6 +112,7 @@ fn generate_cargo_file(
format_cargo_key("description", config.description),
format_cargo_key("readme", config.readme),
format_cargo_key("license", config.license),
format_cargo_key("published", config.published),
dependencies
.iter()
.map(|(name, value)| format!("{name} = {value}"))
Expand Down

0 comments on commit 4b18d22

Please sign in to comment.