Skip to content

Commit 35627a8

Browse files
committed
Renames format-* command-line arguments to rustfmt-*
The --rustfmt-configuration-file command-line argument automatically activates --rustfmt-bindings.
1 parent 31f6ced commit 35627a8

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

src/lib.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,16 @@ impl Builder {
456456
);
457457
}
458458

459-
if !self.options.format_bindings {
460-
output_vector.push("--format-bindings".into());
459+
if !self.options.rustfmt_bindings {
460+
output_vector.push("--rustfmt-bindings".into());
461461
}
462462

463-
if let Some(path) = self.options.format_configuration_file.as_ref().and_then(
464-
|f| f.to_str()) {
465-
output_vector.push("--format-configuration-file".into());
463+
if let Some(path) = self.options
464+
.rustfmt_configuration_file
465+
.as_ref()
466+
.and_then(|f| f.to_str())
467+
{
468+
output_vector.push("--rustfmt-configuration-file".into());
466469
output_vector.push(path.into());
467470
}
468471

@@ -852,15 +855,16 @@ impl Builder {
852855
}
853856

854857
/// Set whether rustfmt should format the generated bindings.
855-
pub fn format_bindings(mut self, doit: bool) -> Self {
856-
self.options.format_bindings = doit;
858+
pub fn rustfmt_bindings(mut self, doit: bool) -> Self {
859+
self.options.rustfmt_bindings = doit;
857860
self
858861
}
859862

860863
/// Set the absolute path to the rustfmt configuration file, if None, the standard rustfmt
861864
/// options are used.
862-
pub fn format_configuration_file(mut self, path: Option<PathBuf>) -> Self {
863-
self.options.format_configuration_file = path;
865+
pub fn rustfmt_configuration_file(mut self, path: Option<PathBuf>) -> Self {
866+
self = self.rustfmt_bindings(true);
867+
self.options.rustfmt_configuration_file = path;
864868
self
865869
}
866870

@@ -1125,11 +1129,11 @@ pub struct BindgenOptions {
11251129
rust_features: RustFeatures,
11261130

11271131
/// Whether rustfmt should format the generated bindings.
1128-
pub format_bindings: bool,
1132+
pub rustfmt_bindings: bool,
11291133

11301134
/// The absolute path to the rustfmt configuration file, if None, the standard rustfmt
11311135
/// options are used.
1132-
pub format_configuration_file: Option<PathBuf>,
1136+
pub rustfmt_configuration_file: Option<PathBuf>,
11331137
}
11341138

11351139
/// TODO(emilio): This is sort of a lie (see the error message that results from
@@ -1214,8 +1218,8 @@ impl Default for BindgenOptions {
12141218
objc_extern_crate: false,
12151219
enable_mangling: true,
12161220
prepend_enum_name: true,
1217-
format_bindings: true,
1218-
format_configuration_file: None,
1221+
rustfmt_bindings: true,
1222+
rustfmt_configuration_file: None,
12191223
}
12201224
}
12211225
}

src/options.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,15 @@ where
233233
Useful when debugging bindgen, using C-Reduce, or when \
234234
filing issues. The resulting file will be named \
235235
something like `__bindgen.i` or `__bindgen.ii`."),
236-
Arg::with_name("format-bindings")
237-
.long("format-bindings")
236+
Arg::with_name("rustfmt-bindings")
237+
.long("rustfmt-bindings")
238238
.help("Format the generated bindings with rustfmt. \
239239
Rustfmt needs to be in the global PATH."),
240-
Arg::with_name("format-configuration-file")
241-
.long("format-configuration-file")
240+
Arg::with_name("rustfmt-configuration-file")
241+
.long("rustfmt-configuration-file")
242242
.help("The absolute path to the rustfmt configuration file. \
243-
The configuration file will be used for formatting the bindings \
244-
(when enabled by --format-bindings).")
243+
The configuration file will be used for formatting the bindings. \
244+
Setting this parameter, will automatically set --rustfmt-bindings.")
245245
.value_name("path")
246246
.takes_value(true)
247247
.multiple(false)
@@ -472,25 +472,25 @@ where
472472
builder.dump_preprocessed_input()?;
473473
}
474474

475-
if matches.is_present("format-bindings") {
476-
builder = builder.format_bindings(true);
475+
if matches.is_present("rustfmt-bindings") {
476+
builder = builder.rustfmt_bindings(true);
477477
}
478478

479-
if let Some(path_str) = matches.value_of("format-configuration-file") {
479+
if let Some(path_str) = matches.value_of("rustfmt-configuration-file") {
480480
let path = PathBuf::from(path_str);
481481

482482
if !path.is_absolute() {
483483
return Err(Error::new(ErrorKind::Other,
484-
"--format-configuration--file needs to be an absolute path!"));
484+
"--rustfmt-configuration--file needs to be an absolute path!"));
485485
}
486486

487487
if path.to_str().is_none() {
488488
return Err(
489489
Error::new(ErrorKind::Other,
490-
"--format-configuration-file contains non-valid UTF8 characters."));
490+
"--rustfmt-configuration-file contains non-valid UTF8 characters."));
491491
}
492492

493-
builder = builder.format_configuration_file(Some(path));
493+
builder = builder.rustfmt_configuration_file(Some(path));
494494
}
495495

496496
let verbose = matches.is_present("verbose");

0 commit comments

Comments
 (0)