@@ -335,46 +335,30 @@ impl<'a> Session<'a> {
335335 } ) )
336336 . collect ( ) ;
337337
338- let header = not_found_name. map ( |name| vite_str:: format!( "Task \" {name}\" not found." ) ) ;
339- let header_str = header. as_deref ( ) ;
340-
341- if is_interactive {
342- self . interactive_task_select (
343- & select_items,
344- not_found_name,
345- header_str,
346- flags,
347- additional_args,
348- )
349- . await
350- } else {
351- Self :: non_interactive_task_list ( & select_items, not_found_name, header_str)
352- }
353- }
338+ // Build header: interactive says "not found.", non-interactive "did you mean:" suffix
339+ let header = not_found_name. map ( |name| {
340+ if is_interactive {
341+ vite_str:: format!( "Task \" {name}\" not found." )
342+ } else {
343+ vite_str:: format!( "Task \" {name}\" not found. Did you mean:" )
344+ }
345+ } ) ;
354346
355- #[ expect(
356- clippy:: future_not_send,
357- reason = "session is single-threaded, futures do not need to be Send"
358- ) ]
359- #[ expect(
360- clippy:: large_futures,
361- reason = "execution plan future is large but only awaited once"
362- ) ]
363- async fn interactive_task_select (
364- & mut self ,
365- items : & [ SelectItem ] ,
366- not_found_name : Option < & str > ,
367- header : Option < & str > ,
368- flags : RunFlags ,
369- additional_args : Vec < Str > ,
370- ) -> anyhow:: Result < ExitStatus > {
347+ // Build mode-dependent params and call select_list once
371348 let mut selected_index = 0usize ;
349+ let mut stdout = std:: io:: stdout ( ) ;
350+ let mode = if is_interactive {
351+ vite_select:: Mode :: Interactive { selected_index : & mut selected_index }
352+ } else {
353+ vite_select:: Mode :: NonInteractive
354+ } ;
355+
372356 vite_select:: select_list (
373- & mut std :: io :: stdout ( ) ,
374- items ,
357+ & mut stdout,
358+ & select_items ,
375359 not_found_name,
376- vite_select :: Mode :: Interactive { selected_index : & mut selected_index } ,
377- header,
360+ mode ,
361+ header. as_deref ( ) ,
378362 8 ,
379363 |state| {
380364 use std:: io:: Write ;
@@ -387,11 +371,17 @@ impl<'a> Session<'a> {
387371 } ,
388372 ) ?;
389373
390- let selected_label = & items[ selected_index] . label ;
374+ if !is_interactive {
375+ return if not_found_name. is_some ( ) {
376+ Ok ( ExitStatus :: FAILURE )
377+ } else {
378+ Ok ( ExitStatus :: SUCCESS )
379+ } ;
380+ }
391381
392- // Parse the selected label back into a TaskSpecifier and re-run
382+ // Interactive: run the selected task
383+ let selected_label = & select_items[ selected_index] . label ;
393384 let task_specifier = TaskSpecifier :: parse_raw ( selected_label) ;
394-
395385 let run_command =
396386 RunCommand { task_specifier : Some ( task_specifier) , flags, additional_args } ;
397387
@@ -401,37 +391,6 @@ impl<'a> Session<'a> {
401391 Ok ( self . execute ( plan, Box :: new ( reporter) ) . await . err ( ) . unwrap_or ( ExitStatus :: SUCCESS ) )
402392 }
403393
404- fn non_interactive_task_list (
405- items : & [ SelectItem ] ,
406- not_found_name : Option < & str > ,
407- header : Option < & str > ,
408- ) -> anyhow:: Result < ExitStatus > {
409- let mut stdout = std:: io:: stdout ( ) . lock ( ) ;
410-
411- // For the "did you mean" case, add suffix to header
412- let did_you_mean_header = not_found_name
413- . map ( |name| vite_str:: format!( "Task \" {name}\" not found. Did you mean:" ) ) ;
414- let effective_header =
415- if not_found_name. is_some ( ) { did_you_mean_header. as_deref ( ) } else { header } ;
416-
417- vite_select:: select_list (
418- & mut stdout,
419- items,
420- not_found_name,
421- vite_select:: Mode :: NonInteractive ,
422- effective_header,
423- 0 ,
424- |_| { } ,
425- ) ?;
426-
427- if not_found_name. is_some ( ) {
428- // Non-interactive typo case should exit with failure
429- Ok ( ExitStatus :: FAILURE )
430- } else {
431- Ok ( ExitStatus :: SUCCESS )
432- }
433- }
434-
435394 /// Lazily initializes and returns the execution cache.
436395 /// The cache is only created when first accessed to avoid `SQLite` race conditions
437396 /// when multiple processes start simultaneously.
0 commit comments