@@ -8,7 +8,7 @@ use std::time::Duration;
88use chrono:: { Local , Timelike } ;
99use color_eyre:: eyre;
1010use color_eyre:: eyre:: Context ;
11- use console:: { Key , Term , measure_text_width, style} ;
11+ use console:: { Color , Key , Term , measure_text_width, style} ;
1212use notify_rust:: { Notification , Timeout } ;
1313use rust_i18n:: t;
1414use tracing:: { debug, error} ;
@@ -44,6 +44,7 @@ struct Terminal {
4444 desktop_notification : bool ,
4545 show_step_ids : bool ,
4646 current_step_id : Option < String > ,
47+ separator_color : Option < Color > ,
4748}
4849
4950impl Terminal {
@@ -58,13 +59,18 @@ impl Terminal {
5859 desktop_notification : false ,
5960 show_step_ids : false ,
6061 current_step_id : None ,
62+ separator_color : None ,
6163 }
6264 }
6365
6466 fn set_show_step_ids ( & mut self , show : bool ) {
6567 self . show_step_ids = show;
6668 }
6769
70+ fn set_separator_color ( & mut self , color : Option < Color > ) {
71+ self . separator_color = color;
72+ }
73+
6874 fn set_current_step_id ( & mut self , step_id : Option < String > ) {
6975 self . current_step_id = step_id;
7076 }
@@ -132,24 +138,25 @@ impl Terminal {
132138
133139 match self . width {
134140 Some ( width) => {
135- self . term
136- . write_fmt ( format_args ! (
137- "{}\n " ,
138- style( format_args!(
139- "\n ── {} {:─^border$}" ,
140- message,
141- "" ,
142- border = max(
143- 2 ,
144- min( 80 , width as usize )
145- . checked_sub( 4 )
146- . and_then( |e| e. checked_sub( measure_text_width( & message) ) )
147- . unwrap_or( 0 )
148- )
149- ) )
150- . bold( )
151- ) )
152- . ok ( ) ;
141+ let styled = style ( format ! (
142+ "\n ── {} {:─^border$}" ,
143+ message,
144+ "" ,
145+ border = max(
146+ 2 ,
147+ min( 80 , width as usize )
148+ . checked_sub( 4 )
149+ . and_then( |e| e. checked_sub( measure_text_width( & message) ) )
150+ . unwrap_or( 0 )
151+ )
152+ ) )
153+ . bold ( ) ;
154+ let styled = if let Some ( color) = self . separator_color {
155+ styled. fg ( color)
156+ } else {
157+ styled
158+ } ;
159+ self . term . write_fmt ( format_args ! ( "{styled}\n " ) ) . ok ( ) ;
153160 }
154161 None => {
155162 self . term . write_fmt ( format_args ! ( "―― {message} ――\n " ) ) . ok ( ) ;
@@ -368,6 +375,28 @@ pub fn set_current_step_id(step_id: Option<String>) {
368375 TERMINAL . lock ( ) . unwrap ( ) . set_current_step_id ( step_id) ;
369376}
370377
378+ /// Parse a color name string into a console::Color.
379+ pub fn parse_color ( name : & str ) -> Option < Color > {
380+ match name. to_lowercase ( ) . as_str ( ) {
381+ "black" => Some ( Color :: Black ) ,
382+ "red" => Some ( Color :: Red ) ,
383+ "green" => Some ( Color :: Green ) ,
384+ "yellow" => Some ( Color :: Yellow ) ,
385+ "blue" => Some ( Color :: Blue ) ,
386+ "magenta" | "purple" => Some ( Color :: Magenta ) ,
387+ "cyan" => Some ( Color :: Cyan ) ,
388+ "white" => Some ( Color :: White ) ,
389+ _ => {
390+ // Try parsing as a 256-color index (e.g., "208" for orange)
391+ name. parse :: < u8 > ( ) . ok ( ) . map ( Color :: Color256 )
392+ }
393+ }
394+ }
395+
396+ pub fn set_separator_color ( color : Option < Color > ) {
397+ TERMINAL . lock ( ) . unwrap ( ) . set_separator_color ( color) ;
398+ }
399+
371400/// Print a summary of all updated components collected during the run.
372401pub fn print_updated_components_summary ( report : & [ ( impl AsRef < str > , StepResult ) ] ) {
373402 let mut any_updates = false ;
0 commit comments