@@ -36,14 +36,14 @@ impl Case {
3636 self . time_closed . is_none ( )
3737 }
3838
39- pub fn display_indented ( & self , indent : usize ) -> impl fmt:: Display + ' _ {
40- DisplayCase { case : self , indent }
39+ pub fn display_indented ( & self , indent : usize , sitrep_id : Option < SitrepUuid > ) -> impl fmt:: Display + ' _ {
40+ DisplayCase { case : self , indent, sitrep_id }
4141 }
4242}
4343
4444impl fmt:: Display for Case {
4545 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
46- self . display_indented ( 0 ) . fmt ( f)
46+ self . display_indented ( 0 , None ) . fmt ( f)
4747 }
4848}
4949
@@ -92,6 +92,7 @@ impl IdOrdItem for ImpactedSpSlot {
9292struct DisplayCase < ' a > {
9393 case : & ' a Case ,
9494 indent : usize ,
95+ sitrep_id : Option < SitrepUuid > ,
9596}
9697
9798impl fmt:: Display for DisplayCase < ' _ > {
@@ -114,17 +115,28 @@ impl fmt::Display for DisplayCase<'_> {
114115 ref comment,
115116 } ,
116117 indent,
118+ sitrep_id,
117119 } = self ;
120+
121+ let this_sitrep = move |s| {
122+ if Some ( s) == sitrep_id {
123+ " <-- this sitrep"
124+ } else {
125+ ""
126+ }
127+ } ;
128+
118129 writeln ! (
119130 f,
120- "{:>indent$}case: {id}" ,
131+ "{:>indent$}case {id}" ,
121132 if indent > 0 { BULLET } else { "" }
122133 ) ?;
134+ writeln ! ( f, "{:>indent$}-----------------------------------------" , "" ) ?;
123135 writeln ! ( f, "{:>indent$}diagnosis engine: {de}" , "" ) ?;
124- writeln ! ( f, "{:>indent$}created in sitrep: {created_sitrep_id}" , "" ) ?;
136+ writeln ! ( f, "{:>indent$}created in sitrep: {created_sitrep_id}{} " , "" , this_sitrep ( * created_sitrep_id ) ) ?;
125137 writeln ! ( f, "{:>indent$} at: {time_created}" , "" ) ?;
126138 if let Some ( closed_id) = closed_sitrep_id {
127- writeln ! ( f, "{:>indent$}closed in sitrep: {closed_id}" , "" ) ?;
139+ writeln ! ( f, "{:>indent$}closed in sitrep: {closed_id}{} " , "" , this_sitrep ( * closed_id ) ) ?;
128140 if let Some ( time_closed) = time_closed {
129141 writeln ! ( f, "{:>indent$} at: {time_closed}" , "" ) ?;
130142 } else {
@@ -145,7 +157,7 @@ impl fmt::Display for DisplayCase<'_> {
145157 . serial_number
146158 . as_deref ( )
147159 . unwrap_or ( "<UNKNOWN SERIAL>" ) ;
148- writeln ! ( f, "{BULLET:>indent$}{}" , ereport. id( ) ) ?;
160+ writeln ! ( f, "{BULLET:>indent$}ereport {}" , ereport. id( ) ) ?;
149161 writeln ! (
150162 f,
151163 "{:>indent$}class: {}" ,
@@ -158,8 +170,9 @@ impl fmt::Display for DisplayCase<'_> {
158170 writeln ! ( f, "{:>indent$} identity: {pn}:{sn}" , "" ) ?;
159171 writeln ! (
160172 f,
161- "{:>indent$}added in sitrep: {assigned_sitrep_id}" ,
162- ""
173+ "{:>indent$}added in sitrep: {assigned_sitrep_id}{}" ,
174+ "" ,
175+ this_sitrep( * assigned_sitrep_id)
163176 ) ?;
164177 writeln ! ( f, "{:>indent$}comment: {comment}\n " , "" ) ?;
165178 }
@@ -174,8 +187,9 @@ impl fmt::Display for DisplayCase<'_> {
174187 writeln ! ( f, "{BULLET:>indent$}{sp_type:<6} {slot:02}" ) ?;
175188 writeln ! (
176189 f,
177- "{:>indent$}added in sitrep: {created_sitrep_id}" ,
178- ""
190+ "{:>indent$}added in sitrep: {created_sitrep_id}{}" ,
191+ "" ,
192+ this_sitrep( * created_sitrep_id)
179193 ) ?;
180194 writeln ! ( f, "{:>indent$}comment: {comment}\n " , "" ) ?;
181195 }
@@ -187,12 +201,13 @@ impl fmt::Display for DisplayCase<'_> {
187201 for AlertRequest { id, class, requested_sitrep_id, .. } in
188202 alerts_requested
189203 {
190- writeln ! ( f, "{BULLET:>indent$}{id}" ) ?;
204+ writeln ! ( f, "{BULLET:>indent$}alert {id}" ) ?;
191205 writeln ! ( f, "{:>indent$}class: {class:?}" , "" ) ?;
192206 writeln ! (
193207 f,
194- "{:>indent$}requested in sitrep: {requested_sitrep_id}\n " ,
195- ""
208+ "{:>indent$}requested in sitrep: {requested_sitrep_id}{}\n " ,
209+ "" ,
210+ this_sitrep( * requested_sitrep_id)
196211 ) ?;
197212 }
198213 }
@@ -318,11 +333,11 @@ mod tests {
318333 } ;
319334
320335 eprintln ! ( "example case display:" ) ;
321- eprintln ! ( "=====================" ) ;
336+ eprintln ! ( "=====================\n " ) ;
322337 eprintln ! ( "{case}" ) ;
323338
324339 eprintln ! ( "example case display (indented by 4):" ) ;
325- eprintln ! ( "======================================" ) ;
326- eprintln ! ( "{}" , case. display_indented( 4 ) ) ;
340+ eprintln ! ( "======================================\n " ) ;
341+ eprintln ! ( "{}" , case. display_indented( 4 , Some ( closed_sitrep_id ) ) ) ;
327342 }
328343}
0 commit comments