Skip to content

Commit 32b491d

Browse files
committed
feat: add stubs flag
Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
1 parent a74d2f2 commit 32b491d

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/bindings.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ pub fn generate_bindings(
77
world: Option<&str>,
88
features: &[String],
99
all_features: bool,
10+
generate_stubs: bool,
1011
output: Option<&Path>,
1112
) -> Result<()> {
1213
let (resolve, world) = parse_wit(wit_path, world, features, all_features)?;
1314
let mut files = Default::default();
1415

15-
wit_bindgen_go::Opts::default()
16-
.build()
17-
.generate(&resolve, world, &mut files)?;
16+
wit_bindgen_go::Opts {
17+
generate_stubs,
18+
..Default::default()
19+
}
20+
.build()
21+
.generate(&resolve, world, &mut files)?;
1822

1923
let output_path = match output {
2024
Some(p) => {

src/command.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ pub struct Bindings {
8383
/// This will be created if it does not already exist.
8484
#[arg(long, short = 'o')]
8585
pub output: Option<PathBuf>,
86+
87+
/// If true, generate stub functions for any exported functions and/or resources.
88+
///
89+
/// A stub function is a placeholder method which has not yet been implemented.
90+
#[arg(long)]
91+
pub generate_stubs: bool,
8692
}
8793

8894
fn componentize(common: Common, componentize: Componentize) -> Result<()> {
@@ -113,6 +119,7 @@ fn bindings(common: Common, bindings: Bindings) -> Result<()> {
113119
common.world.as_deref(),
114120
&common.features,
115121
common.all_features,
122+
bindings.generate_stubs,
116123
bindings.output.as_deref(),
117124
)
118125
}

0 commit comments

Comments
 (0)