@@ -23,13 +23,11 @@ where
23
23
) ;
24
24
25
25
let matches = App :: new ( "bindgen" )
26
- . version ( option_env ! ( "CARGO_PKG_VERSION" ) . unwrap_or ( "unknown" ) )
27
26
. about ( "Generates Rust bindings from C/C++ headers." )
28
27
. usage ( "bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>..." )
29
28
. args ( & [
30
29
Arg :: with_name ( "header" )
31
- . help ( "C or C++ header file" )
32
- . required ( true ) ,
30
+ . help ( "C or C++ header file" ) ,
33
31
Arg :: with_name ( "depfile" )
34
32
. long ( "depfile" )
35
33
. takes_value ( true )
@@ -534,9 +532,22 @@ where
534
532
Arg :: with_name ( "explicit-padding" )
535
533
. long ( "explicit-padding" )
536
534
. help ( "Always output explicit padding fields." ) ,
535
+ Arg :: with_name ( "V" )
536
+ . long ( "version" )
537
+ . help ( "Prints the version, and exits" ) ,
537
538
] ) // .args()
538
539
. get_matches_from ( args) ;
539
540
541
+ let verbose = matches. is_present ( "verbose" ) ;
542
+
543
+ if matches. is_present ( "V" ) {
544
+ println ! ( "bindgen {}" , option_env!( "CARGO_PKG_VERSION" ) . unwrap_or( "unknown" ) ) ;
545
+ if verbose {
546
+ println ! ( "Clang version: {}" , crate :: clang_version( ) . full) ;
547
+ }
548
+ std:: process:: exit ( 0 ) ;
549
+ }
550
+
540
551
let mut builder = builder ( ) ;
541
552
542
553
if let Some ( header) = matches. value_of ( "header" ) {
@@ -994,7 +1005,5 @@ where
994
1005
builder = builder. explicit_padding ( true ) ;
995
1006
}
996
1007
997
- let verbose = matches. is_present ( "verbose" ) ;
998
-
999
1008
Ok ( ( builder, output, verbose) )
1000
1009
}
0 commit comments