@@ -128,7 +128,7 @@ pub fn builder() -> Builder {
128
128
pub fn builder_from_flags < I > ( args : I ) -> Result < ( Builder , Box < io:: Write > ) , io:: Error >
129
129
where I : Iterator < Item =String >
130
130
{
131
- let mmm = App :: new ( "bindgen" )
131
+ let matches = App :: new ( "bindgen" )
132
132
. version ( env ! ( "CARGO_PKG_VERSION" ) )
133
133
. about ( "Generates Rust bindings from C/C++ headers." )
134
134
. usage ( "bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>..." )
@@ -141,13 +141,15 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
141
141
. help ( "Mark any enum whose name matches <regex> as a set of bitfield flags instead of an enumeration." )
142
142
. value_name ( "regex" )
143
143
. takes_value ( true )
144
- . multiple ( true ) ,
144
+ . multiple ( true )
145
+ . number_of_values ( 1 ) ,
145
146
Arg :: with_name ( "blacklist-type" )
146
147
. long ( "blacklist-type" )
147
148
. help ( "Mark a type as hidden." )
148
149
. value_name ( "type" )
149
150
. takes_value ( true )
150
- . multiple ( true ) ,
151
+ . multiple ( true )
152
+ . number_of_values ( 1 ) ,
151
153
Arg :: with_name ( "builtins" )
152
154
. long ( "builtins" )
153
155
. help ( "Output bindings for builtin definitions, e.g. __builtin_va_list." ) ,
@@ -156,6 +158,7 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
156
158
. help ( "Use the given prefix before raw types instead of ::std::os::raw." )
157
159
. value_name ( "prefix" )
158
160
. takes_value ( true ) ,
161
+ // All positional arguments after the end of options marker, `--`
159
162
Arg :: with_name ( "clang-args" )
160
163
. multiple ( true ) ,
161
164
Arg :: with_name ( "dummy-uses" )
@@ -172,7 +175,8 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
172
175
. long ( "framework-link" )
173
176
. help ( "Link to framework." )
174
177
. takes_value ( true )
175
- . multiple ( true ) ,
178
+ . multiple ( true )
179
+ . number_of_values ( 1 ) ,
176
180
Arg :: with_name ( "ignore-functions" )
177
181
. long ( "ignore-functions" )
178
182
. help ( "Do not generate bindings for functions or methods. This is useful when you only care about struct layouts." ) ,
@@ -184,7 +188,8 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
184
188
. long ( "link" )
185
189
. help ( "Link to dynamic library." )
186
190
. takes_value ( true )
187
- . multiple ( true ) ,
191
+ . multiple ( true )
192
+ . number_of_values ( 1 ) ,
188
193
Arg :: with_name ( "no-unstable-rust" )
189
194
. long ( "no-unstable-rust" )
190
195
. help ( "Do not generate unstable Rust code." ) ,
@@ -193,7 +198,8 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
193
198
. help ( "Mark a type as opaque." )
194
199
. value_name ( "type" )
195
200
. takes_value ( true )
196
- . multiple ( true ) ,
201
+ . multiple ( true )
202
+ . number_of_values ( 1 ) ,
197
203
Arg :: with_name ( "output" )
198
204
. short ( "o" )
199
205
. long ( "output" )
@@ -203,12 +209,14 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
203
209
. long ( "raw-line" )
204
210
. help ( "Add a raw line of Rust code at the beginning of output." )
205
211
. takes_value ( true )
206
- . multiple ( true ) ,
212
+ . multiple ( true )
213
+ . number_of_values ( 1 ) ,
207
214
Arg :: with_name ( "static" )
208
215
. long ( "static-link" )
209
216
. help ( "Link to static library." )
210
217
. takes_value ( true )
211
- . multiple ( true ) ,
218
+ . multiple ( true )
219
+ . number_of_values ( 1 ) ,
212
220
Arg :: with_name ( "use-core" )
213
221
. long ( "use-core" )
214
222
. help ( "Use types from Rust core instead of std." ) ,
@@ -220,28 +228,24 @@ pub fn builder_from_flags<I>(args: I) -> Result<(Builder, Box<io::Write>), io::E
220
228
. help ( "Whitelist all the free-standing functions matching <regex>. Other non-whitelisted functions will not be generated." )
221
229
. value_name ( "regex" )
222
230
. takes_value ( true )
223
- . multiple ( true ) ,
231
+ . multiple ( true )
232
+ . number_of_values ( 1 ) ,
224
233
Arg :: with_name ( "whitelist-type" )
225
234
. long ( "whitelist-type" )
226
235
. help ( "Whitelist the type. Other non-whitelisted types will not be generated." )
227
236
. value_name ( "type" )
228
237
. takes_value ( true )
229
- . multiple ( true ) ,
238
+ . multiple ( true )
239
+ . number_of_values ( 1 ) ,
230
240
Arg :: with_name ( "whitelist-var" )
231
241
. long ( "whitelist-var" )
232
242
. help ( "Whitelist all the free-standing variables matching <regex>. Other non-whitelisted variables will not be generated." )
233
243
. value_name ( "regex" )
234
244
. takes_value ( true )
235
- . multiple ( true ) ,
245
+ . multiple ( true )
246
+ . number_of_values ( 1 ) ,
236
247
] ) // .args()
237
- . get_matches_from_safe ( args) ;
238
-
239
- match mmm {
240
- Ok ( ref m) => println ! ( "{:#?}" , m) ,
241
- Err ( ref e) => println ! ( "{:#?}" , e)
242
- } ;
243
-
244
- let matches = mmm. unwrap ( ) ;
248
+ . get_matches_from ( args) ;
245
249
246
250
let mut builder = builder ( ) ;
247
251
0 commit comments