@@ -68,14 +68,6 @@ pub struct Componentize {
6868 pub mod_path : Option < PathBuf > ,
6969}
7070
71- pub fn run < T : Into < OsString > + Clone , I : IntoIterator < Item = T > > ( args : I ) -> Result < ( ) > {
72- let options = Options :: parse_from ( args) ;
73- match options. command {
74- Command :: Componentize ( opts) => componentize ( options. common , opts) ,
75- Command :: Bindings ( opts) => bindings ( options. common , opts) ,
76- }
77- }
78-
7971#[ derive( Parser ) ]
8072pub struct Bindings {
8173 /// Output directory for bindings (or current directory if `None`).
@@ -88,9 +80,23 @@ pub struct Bindings {
8880 #[ arg( long) ]
8981 pub generate_stubs : bool ,
9082
91- #[ arg( long) ]
9283 /// Whether or not `gofmt` should be used (if present) to format generated code.
84+ #[ arg( long) ]
9385 pub format : bool ,
86+
87+ /// The name of the Go module housing the generated bindings (or "wit_component" if `None`).
88+ ///
89+ /// This option is used if the generated bindings will be used as a library.
90+ #[ arg( long) ]
91+ pub mod_name : Option < String > ,
92+ }
93+
94+ pub fn run < T : Into < OsString > + Clone , I : IntoIterator < Item = T > > ( args : I ) -> Result < ( ) > {
95+ let options = Options :: parse_from ( args) ;
96+ match options. command {
97+ Command :: Componentize ( opts) => componentize ( options. common , opts) ,
98+ Command :: Bindings ( opts) => bindings ( options. common , opts) ,
99+ }
94100}
95101
96102fn componentize ( common : Common , componentize : Componentize ) -> Result < ( ) > {
@@ -124,5 +130,6 @@ fn bindings(common: Common, bindings: Bindings) -> Result<()> {
124130 bindings. generate_stubs ,
125131 bindings. format ,
126132 bindings. output . as_deref ( ) ,
133+ bindings. mod_name ,
127134 )
128135}
0 commit comments