@@ -26,7 +26,7 @@ pub struct CatBox {
2626
2727/// CatBoxContext for storing running result
2828pub trait CatBoxContext {
29- fn add_result ( & mut self , label : & String , result : CatBoxResult ) ;
29+ fn add_result ( & mut self , label : & String , result : CatBoxResult ) -> bool ;
3030
3131 fn report ( & self ) {
3232 let is_tty = isatty ( STDOUT_FILENO ) . unwrap_or ( false ) ;
@@ -100,9 +100,10 @@ impl CatBox {
100100 /// Run all the commands
101101 pub fn start ( & mut self ) -> Result < ( ) , CatBoxError > {
102102 for option in self . options . iter ( ) {
103- dbg ! ( & option) ;
104103 let result = crate :: run ( & option) ?;
105- self . context . add_result ( & option. label . clone ( ) , result) ;
104+ if !self . context . add_result ( & option. label . clone ( ) , result) {
105+ break ;
106+ }
106107 }
107108 Ok ( ( ) )
108109 }
@@ -189,12 +190,13 @@ impl CatBoxRunContext {
189190}
190191
191192impl CatBoxContext for CatBoxRunContext {
192- fn add_result ( & mut self , _label : & String , result : CatBoxResult ) {
193+ fn add_result ( & mut self , _label : & String , result : CatBoxResult ) -> bool {
193194 self . max_time = max ( self . max_time , result. time ) ;
194195 self . max_memory = max ( self . max_memory , result. memory ) ;
195196 self . sum_time += result. time ;
196197 self . sum_memory += result. memory ;
197198 self . results . push ( result) ;
199+ true
198200 }
199201
200202 fn report_human ( & self ) {
@@ -254,11 +256,16 @@ impl CatBoxCompileContext {
254256}
255257
256258impl CatBoxContext for CatBoxCompileContext {
257- fn add_result ( & mut self , _label : & String , result : CatBoxResult ) {
259+ fn add_result ( & mut self , _label : & String , result : CatBoxResult ) -> bool {
258260 if self . ok {
259261 if result. status . unwrap_or ( 1 ) == 0 {
260- self . ok = false ;
262+ self . ok = true ;
263+ true
264+ } else {
265+ false
261266 }
267+ } else {
268+ false
262269 }
263270 }
264271
@@ -272,7 +279,7 @@ impl CatBoxContext for CatBoxCompileContext {
272279}
273280
274281impl CatBoxContext for CatBoxJudgeContext {
275- fn add_result ( & mut self , _label : & String , result : CatBoxResult ) {
282+ fn add_result ( & mut self , _label : & String , result : CatBoxResult ) -> bool {
276283 todo ! ( )
277284 }
278285
0 commit comments