1515from .output import Level
1616
1717if TYPE_CHECKING :
18+ from typing import List
19+
1820 from organize .resource import Resource
1921
2022 from ._sender import SenderType
@@ -51,7 +53,7 @@ def set_error_msg(cls, msg: str) -> None:
5153
5254
5355class Default :
54- def __init__ (self , theme : Optional [Theme ] = None ):
56+ def __init__ (self , theme : Optional [Theme ] = None , errors_only : bool = False ):
5557 if theme is None :
5658 theme = Theme (
5759 {
@@ -74,6 +76,10 @@ def __init__(self, theme: Optional[Theme] = None):
7476 "summary.fail" : "red" ,
7577 }
7678 )
79+ self .errors_only = errors_only
80+ self .msg_queue : List [str ] = []
81+ self .det_resource = ChangeDetector ()
82+
7783 self .console = Console (theme = theme , highlight = False )
7884
7985 self .status = Status ("" , console = self .console )
@@ -141,14 +147,25 @@ def msg(
141147 sender : SenderType ,
142148 level : Level = "info" ,
143149 ) -> None :
144- self .show_resource (res )
145150 msg_pre = format_sender (sender = sender , standalone = res .path is None )
146151 if level == "info" :
147- self .console .print (f"{ msg_pre } { format_info (msg = msg )} " )
148- elif level == "error" :
149- self .console .print (f"{ msg_pre } { format_error (msg = msg )} " )
152+ msg = f"{ msg_pre } { format_info (msg = msg )} "
150153 elif level == "warn" :
151- self .console .print (f"{ msg_pre } { format_warn (msg = msg )} " )
154+ msg = f"{ msg_pre } { format_warn (msg = msg )} "
155+ elif level == "error" :
156+ msg = f"{ msg_pre } { format_error (msg = msg )} "
157+
158+ if self .errors_only :
159+ if self .det_resource .changed (res ):
160+ self .msg_queue .clear ()
161+ self .msg_queue .append (msg )
162+ if level == "error" :
163+ self .show_resource (res )
164+ for msg in self .msg_queue :
165+ self .console .print (msg )
166+ else :
167+ self .show_resource (res )
168+ self .console .print (msg )
152169
153170 def confirm (
154171 self ,
0 commit comments