Skip to content

Commit eee8c31

Browse files
committed
Clap *does* support the end of options marker!
1 parent be30be3 commit eee8c31

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/lib.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,6 @@ pub fn builder() -> Builder {
125125
pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
126126
where I: Iterator<Item=String>
127127
{
128-
// clap doesn't support the end of options marker, --
129-
// https://github.com/kbknapp/clap-rs/issues/735
130-
let mut terminated = false;
131-
let (bindgen_args, clang_args): (Vec<_>, Vec<_>) = args.partition(|arg| {
132-
if terminated { // clang arg
133-
false
134-
} else if arg == "--" {
135-
terminated = true; // end of bindgen args, start of clang args
136-
false
137-
} else { // bindgen arg
138-
true
139-
}
140-
});
141-
142128
let matches = App::new("bindgen")
143129
.version(env!("CARGO_PKG_VERSION"))
144130
.about("Generates Rust bindings from C/C++ headers.")
@@ -167,6 +153,8 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
167153
.help("Use the given prefix before raw types instead of ::std::os::raw.")
168154
.value_name("prefix")
169155
.takes_value(true),
156+
Arg::with_name("clang-args")
157+
.multiple(true),
170158
Arg::with_name("dummy-uses")
171159
.long("dummy-uses")
172160
.help("For testing purposes, generate a C/C++ file containing dummy uses of all types defined in the input header.")
@@ -243,7 +231,7 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
243231
.takes_value(true)
244232
.multiple(true),
245233
]) // .args()
246-
.get_matches_from(bindgen_args);
234+
.get_matches_from(args);
247235

248236
let mut builder = builder();
249237

@@ -349,8 +337,10 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
349337
}
350338
}
351339

352-
for arg in clang_args.into_iter().skip(1) {
353-
builder = builder.clang_arg(arg);
340+
if let Some(args) = matches.values_of("clang-args") {
341+
for arg in args {
342+
builder = builder.clang_arg(arg);
343+
}
354344
}
355345

356346
// FIXME: hrrrmmm

0 commit comments

Comments
 (0)