@@ -8,33 +8,51 @@ use serde::Serialize;
88pub struct Title {
99 pub git_username : String ,
1010 pub git_version : String ,
11+
1112 #[ serde( skip_serializing) ]
1213 pub title_color : DynColors ,
1314 #[ serde( skip_serializing) ]
14- pub tilde_color : DynColors ,
15+ pub is_title_bold : bool ,
16+
1517 #[ serde( skip_serializing) ]
16- pub underline_color : DynColors ,
18+ pub separator : String ,
19+ #[ serde( skip_serializing) ]
20+ pub separator_color : DynColors ,
21+ #[ serde( skip_serializing) ]
22+ pub is_separator_bold : bool ,
23+
1724 #[ serde( skip_serializing) ]
18- pub is_bold : bool ,
25+ pub underline : String ,
26+ #[ serde( skip_serializing) ]
27+ pub underline_color : DynColors ,
1928}
2029
2130impl Title {
2231 pub fn new (
2332 repo : & Repository ,
33+
2434 title_color : DynColors ,
25- tilde_color : DynColors ,
35+ is_title_bold : bool ,
36+
37+ separator : String ,
38+ separator_color : DynColors ,
39+ is_separator_bold : bool ,
40+
41+ underline : String ,
2642 underline_color : DynColors ,
27- is_bold : bool ,
2843 ) -> Self {
2944 let git_username = get_git_username ( repo) ;
3045 let git_version = cli:: get_git_version ( ) ;
3146 Self {
3247 git_username,
3348 git_version,
3449 title_color,
35- tilde_color,
50+ is_title_bold,
51+ separator,
52+ separator_color,
53+ is_separator_bold,
54+ underline,
3655 underline_color,
37- is_bold,
3856 }
3957 }
4058}
@@ -49,16 +67,16 @@ impl std::fmt::Display for Title {
4967 fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
5068 if !& self . git_username . is_empty ( ) || !& self . git_version . is_empty ( ) {
5169 let git_info_length = self . git_username . len ( ) + self . git_version . len ( ) ;
52- let title_style = get_style ( self . is_bold , self . title_color ) ;
70+ let title_style = get_style ( self . is_title_bold , self . title_color ) ;
5371
5472 let ( git_info_field_str, git_info_field_len) =
5573 if !& self . git_username . is_empty ( ) && !& self . git_version . is_empty ( ) {
56- let tilde_style = get_style ( self . is_bold , self . tilde_color ) ;
74+ let separator_style = get_style ( self . is_separator_bold , self . separator_color ) ;
5775 (
5876 format ! (
5977 "{} {} {}" ,
6078 & self . git_username. style( title_style) ,
61- "~" . style( tilde_style ) ,
79+ & self . separator . style( separator_style ) ,
6280 & self . git_version. style( title_style)
6381 ) ,
6482 git_info_length + 3 ,
@@ -75,8 +93,8 @@ impl std::fmt::Display for Title {
7593 } ;
7694
7795 writeln ! ( f, "{git_info_field_str}" ) ?;
78- let separator = "-" . repeat ( git_info_field_len) ;
79- writeln ! ( f, "{}" , separator . color( self . underline_color) )
96+ let underline = self . underline . repeat ( git_info_field_len) ;
97+ writeln ! ( f, "{}" , underline . color( self . underline_color) )
8098 } else {
8199 Ok ( ( ) )
82100 }
@@ -94,19 +112,22 @@ mod tests {
94112 git_username : "onefetch-committer-name" . to_string ( ) ,
95113 git_version : "git v2.37.2" . to_string ( ) ,
96114 title_color : DynColors :: Ansi ( AnsiColors :: Red ) ,
97- tilde_color : DynColors :: Ansi ( AnsiColors :: White ) ,
115+ is_title_bold : true ,
116+ separator : "->" . to_string ( ) ,
117+ separator_color : DynColors :: Ansi ( AnsiColors :: White ) ,
118+ is_separator_bold : false ,
119+ underline : "_" . to_string ( ) ,
98120 underline_color : DynColors :: Ansi ( AnsiColors :: Blue ) ,
99- is_bold : true ,
100121 } ;
101122
102123 title. git_version = "git v2.37.2" . to_string ( ) ;
103124 assert ! ( title. to_string( ) . contains( "onefetch-committer-name" ) ) ;
104- assert ! ( title. to_string( ) . contains( '~' ) ) ;
125+ assert ! ( title. to_string( ) . contains( "->" ) ) ;
105126 assert ! ( title. to_string( ) . contains( "git v2.37.2" ) ) ;
106127
107128 title. git_version = String :: new ( ) ;
108129 assert ! ( title. to_string( ) . contains( "onefetch-committer-name" ) ) ;
109- assert ! ( !title. to_string( ) . contains( '~' ) ) ;
130+ assert ! ( !title. to_string( ) . contains( "->" ) ) ;
110131 assert ! ( !title. to_string( ) . contains( "git v2.37.2" ) ) ;
111132
112133 title. git_username = String :: new ( ) ;
0 commit comments