@@ -8,33 +8,51 @@ use serde::Serialize;
8
8
pub struct Title {
9
9
pub git_username : String ,
10
10
pub git_version : String ,
11
+
11
12
#[ serde( skip_serializing) ]
12
13
pub title_color : DynColors ,
13
14
#[ serde( skip_serializing) ]
14
- pub tilde_color : DynColors ,
15
+ pub is_title_bold : bool ,
16
+
15
17
#[ 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
+
17
24
#[ serde( skip_serializing) ]
18
- pub is_bold : bool ,
25
+ pub underline : String ,
26
+ #[ serde( skip_serializing) ]
27
+ pub underline_color : DynColors ,
19
28
}
20
29
21
30
impl Title {
22
31
pub fn new (
23
32
repo : & Repository ,
33
+
24
34
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 ,
26
42
underline_color : DynColors ,
27
- is_bold : bool ,
28
43
) -> Self {
29
44
let git_username = get_git_username ( repo) ;
30
45
let git_version = cli:: get_git_version ( ) ;
31
46
Self {
32
47
git_username,
33
48
git_version,
34
49
title_color,
35
- tilde_color,
50
+ is_title_bold,
51
+ separator,
52
+ separator_color,
53
+ is_separator_bold,
54
+ underline,
36
55
underline_color,
37
- is_bold,
38
56
}
39
57
}
40
58
}
@@ -49,16 +67,16 @@ impl std::fmt::Display for Title {
49
67
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
50
68
if !& self . git_username . is_empty ( ) || !& self . git_version . is_empty ( ) {
51
69
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 ) ;
53
71
54
72
let ( git_info_field_str, git_info_field_len) =
55
73
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 ) ;
57
75
(
58
76
format ! (
59
77
"{} {} {}" ,
60
78
& self . git_username. style( title_style) ,
61
- "~" . style( tilde_style ) ,
79
+ & self . separator . style( separator_style ) ,
62
80
& self . git_version. style( title_style)
63
81
) ,
64
82
git_info_length + 3 ,
@@ -75,8 +93,8 @@ impl std::fmt::Display for Title {
75
93
} ;
76
94
77
95
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) )
80
98
} else {
81
99
Ok ( ( ) )
82
100
}
@@ -94,19 +112,22 @@ mod tests {
94
112
git_username : "onefetch-committer-name" . to_string ( ) ,
95
113
git_version : "git v2.37.2" . to_string ( ) ,
96
114
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 ( ) ,
98
120
underline_color : DynColors :: Ansi ( AnsiColors :: Blue ) ,
99
- is_bold : true ,
100
121
} ;
101
122
102
123
title. git_version = "git v2.37.2" . to_string ( ) ;
103
124
assert ! ( title. to_string( ) . contains( "onefetch-committer-name" ) ) ;
104
- assert ! ( title. to_string( ) . contains( '~' ) ) ;
125
+ assert ! ( title. to_string( ) . contains( "->" ) ) ;
105
126
assert ! ( title. to_string( ) . contains( "git v2.37.2" ) ) ;
106
127
107
128
title. git_version = String :: new ( ) ;
108
129
assert ! ( title. to_string( ) . contains( "onefetch-committer-name" ) ) ;
109
- assert ! ( !title. to_string( ) . contains( '~' ) ) ;
130
+ assert ! ( !title. to_string( ) . contains( "->" ) ) ;
110
131
assert ! ( !title. to_string( ) . contains( "git v2.37.2" ) ) ;
111
132
112
133
title. git_username = String :: new ( ) ;
0 commit comments