@@ -93,17 +93,16 @@ fn handle_display_errors(err: Error) -> ! {
9393 let usage_label = translate ! ( "common-usage" ) ;
9494 let localized_help = help_text. replace ( "Usage:" , & format ! ( "{usage_label}:" ) ) ;
9595
96- print ! ( "{}" , localized_help) ;
97- std:: process:: exit ( 0 ) ;
96+ print ! ( "{localized_help}" ) ;
9897 }
9998 ErrorKind :: DisplayVersion => {
10099 // For version, use clap's built-in formatting and exit with 0
101100 // Output to stdout as expected by tests
102101 print ! ( "{}" , err. render( ) ) ;
103- std:: process:: exit ( 0 ) ;
104102 }
105103 _ => unreachable ! ( "handle_display_errors called with non-display error" ) ,
106104 }
105+ std:: process:: exit ( 0 ) ;
107106}
108107
109108/// Handle UnknownArgument errors with localization and suggestions
@@ -243,8 +242,8 @@ fn handle_invalid_value_error(err: Error, maybe_colorize: impl Fn(&str, Color) -
243242 } else {
244243 // Fallback if we can't extract context - use clap's default formatting
245244 let rendered_str = err. render ( ) . to_string ( ) ;
246- let lines : Vec < & str > = rendered_str . lines ( ) . collect ( ) ;
247- if let Some ( main_error_line) = lines. first ( ) {
245+
246+ if let Some ( main_error_line) = rendered_str . lines ( ) . next ( ) {
248247 eprintln ! ( "{main_error_line}" ) ;
249248 eprintln ! ( ) ;
250249 eprintln ! ( "{}" , translate!( "common-help-suggestion" ) ) ;
@@ -284,10 +283,9 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
284283 }
285284
286285 // For other simple validation errors, use the same simple format as other errors
287- let lines: Vec < & str > = rendered_str. lines ( ) . collect ( ) ;
288- if let Some ( main_error_line) = lines. first ( ) {
286+ if let Some ( main_error_line) = rendered_str. lines ( ) . next ( ) {
289287 // Keep the "error: " prefix for test compatibility
290- eprintln ! ( "{}" , main_error_line ) ;
288+ eprintln ! ( "{main_error_line}" ) ;
291289 eprintln ! ( ) ;
292290 // Use the execution phrase for the help suggestion to match test expectations
293291 eprintln ! ( "{}" , translate!( "common-help-suggestion" ) ) ;
@@ -323,11 +321,10 @@ pub fn handle_clap_error_with_exit_code(err: Error, util_name: &str, exit_code:
323321
324322 // For other errors, show just the error and help suggestion
325323 let rendered_str = err. render ( ) . to_string ( ) ;
326- let lines: Vec < & str > = rendered_str. lines ( ) . collect ( ) ;
327324
328325 // Print error message (first line)
329- if let Some ( first_line) = lines. first ( ) {
330- eprintln ! ( "{}" , first_line ) ;
326+ if let Some ( first_line) = rendered_str . lines ( ) . next ( ) {
327+ eprintln ! ( "{first_line}" ) ;
331328 }
332329
333330 // For other errors, just show help suggestion
0 commit comments