From fa9358cba3d72990e0800f78234c7ee2cfdbec78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 1 Nov 2023 21:56:28 +0100 Subject: [PATCH 1/2] fix(args): make header argument optional fixes #2677 --- bindgen-cli/options.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bindgen-cli/options.rs b/bindgen-cli/options.rs index d52ccb8e89..b1cae9b527 100644 --- a/bindgen-cli/options.rs +++ b/bindgen-cli/options.rs @@ -8,6 +8,7 @@ use clap::error::{Error, ErrorKind}; use clap::{CommandFactory, Parser}; use std::fs::File; use std::io; +use std::io::{Error as IoError, ErrorKind as IoErrorKind}; use std::path::{Path, PathBuf}; use std::process::exit; @@ -95,7 +96,7 @@ fn parse_custom_derive( )] struct BindgenCommand { /// C or C++ header file. - header: String, + header: Option, /// Path to write depfile to. #[arg(long)] depfile: Option, @@ -589,7 +590,11 @@ where let mut builder = builder(); - builder = builder.header(header); + if let Some(header) = header { + builder = builder.header(header); + } else { + return Err(IoError::new(IoErrorKind::Other, "Header not found")); + } if let Some(rust_target) = rust_target { builder = builder.rust_target(rust_target); From 5607d8586531650afad4852fa2bb3c4612f3fe66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 2 Nov 2023 10:57:07 +0100 Subject: [PATCH 2/2] refactor(args): avoid using type aliases --- bindgen-cli/options.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bindgen-cli/options.rs b/bindgen-cli/options.rs index b1cae9b527..f82d391901 100644 --- a/bindgen-cli/options.rs +++ b/bindgen-cli/options.rs @@ -8,7 +8,6 @@ use clap::error::{Error, ErrorKind}; use clap::{CommandFactory, Parser}; use std::fs::File; use std::io; -use std::io::{Error as IoError, ErrorKind as IoErrorKind}; use std::path::{Path, PathBuf}; use std::process::exit; @@ -593,7 +592,7 @@ where if let Some(header) = header { builder = builder.header(header); } else { - return Err(IoError::new(IoErrorKind::Other, "Header not found")); + return Err(io::Error::new(io::ErrorKind::Other, "Header not found")); } if let Some(rust_target) = rust_target {