@@ -506,7 +506,7 @@ impl Options {
506
506
Err ( err) => dcx. fatal ( err) ,
507
507
} ;
508
508
509
- let parts_paths = match parse_fetch_parts ( matches) {
509
+ let parts_paths = match parse_include_info_json ( matches) {
510
510
Ok ( ex) => ex,
511
511
Err ( err) => dcx. fatal ( err) ,
512
512
} ;
@@ -751,13 +751,11 @@ impl Options {
751
751
let extern_html_root_takes_precedence =
752
752
matches. opt_present ( "extern-html-root-takes-precedence" ) ;
753
753
let html_no_source = matches. opt_present ( "html-no-source" ) ;
754
- let Ok ( read_rendered_cci) = matches. opt_get_default ( "read-rendered-cci" , true ) else {
755
- dcx. fatal ( format ! ( "read-rendered-cci only accepts true and false" ) )
754
+ let MergeResult { read_rendered_cci, write_rendered_cci } = match parse_merge ( matches) {
755
+ Ok ( result) => result,
756
+ Err ( e) => dcx. fatal ( format ! ( "could not parse --merge: {e}" ) ) ,
756
757
} ;
757
- let Ok ( write_rendered_cci) = matches. opt_get_default ( "write-rendered-cci" , true ) else {
758
- dcx. fatal ( format ! ( "write-rendered-cci only accepts true and false" ) )
759
- } ;
760
- let parts_out_dir = matches. opt_str ( "parts-out-dir" ) . map ( PathBuf :: from) . map ( PathToParts :: from_doc_root) ;
758
+ let parts_out_dir = matches. opt_str ( "write-info-json" ) . map ( |p| PathToParts :: from_doc_root ( PathBuf :: from ( p) ) ) ;
761
759
762
760
if generate_link_to_definition && ( show_coverage || output_format != OutputFormat :: Html ) {
763
761
dcx. fatal (
@@ -943,17 +941,35 @@ impl PathToParts {
943
941
}
944
942
}
945
943
946
- /// Extracts `--fetch-parts ` arguments from `matches` and returns a map of crate names to
947
- /// the given locations. If an `--fetch-parts ` argument was ill-formed, returns an error
944
+ /// Extracts `--include-info-json ` arguments from `matches` and returns a map of crate names to
945
+ /// the given locations. If an `--include-info-json ` argument was ill-formed, returns an error
948
946
/// describing the issue.
949
- fn parse_fetch_parts (
947
+ fn parse_include_info_json (
950
948
matches : & getopts:: Matches ,
951
949
) -> Result < FxHashMap < String , PathToParts > , & ' static str > {
952
950
let mut externs = FxHashMap :: default ( ) ;
953
- for arg in & matches. opt_strs ( "fetch-parts " ) {
951
+ for arg in & matches. opt_strs ( "include-info-json " ) {
954
952
let ( name, path) =
955
- arg. split_once ( '=' ) . ok_or ( "--fetch-parts must be of the form name=path " ) ?;
953
+ arg. split_once ( '=' ) . ok_or ( "--include-info-json must be of the form NAME=PATH " ) ?;
956
954
externs. insert ( name. to_string ( ) , PathToParts :: from_doc_root ( PathBuf :: from ( path) ) ) ;
957
955
}
958
956
Ok ( externs)
959
957
}
958
+
959
+ struct MergeResult {
960
+ read_rendered_cci : bool ,
961
+ write_rendered_cci : bool ,
962
+ }
963
+
964
+ /// Extracts read_rendered_cci and write_rendered_cci from command line arguments, or
965
+ /// reports an error.
966
+ fn parse_merge ( matches : & getopts:: Matches ) -> Result < MergeResult , & ' static str > {
967
+ match matches. opt_str ( "merge" ) . as_deref ( ) {
968
+ // default = auto
969
+ None => Ok ( MergeResult { read_rendered_cci : true , write_rendered_cci : true } ) ,
970
+ Some ( "auto" ) => Ok ( MergeResult { read_rendered_cci : true , write_rendered_cci : true } ) ,
971
+ Some ( "none" ) => Ok ( MergeResult { read_rendered_cci : false , write_rendered_cci : false } ) ,
972
+ Some ( "write-only" ) => Ok ( MergeResult { read_rendered_cci : false , write_rendered_cci : true } ) ,
973
+ Some ( _) => Err ( "argument to --merge must be `auto`, `none`, or `write-only`" ) ,
974
+ }
975
+ }
0 commit comments