@@ -1151,20 +1151,22 @@ def pexcept(self, msg: Any, *, end: str = '\n', apply_style: bool = True) -> Non
1151
1151
1152
1152
self .perror (final_msg , end = end , apply_style = False )
1153
1153
1154
- def pfeedback (self , msg : Any , * , end : str = '\n ' ) -> None :
1154
+ def pfeedback (self , msg : Any , * , end : str = '\n ' , apply_style : bool = True ) -> None :
1155
1155
"""For printing nonessential feedback. Can be silenced with `quiet`.
1156
1156
Inclusion in redirected output is controlled by `feedback_to_output`.
1157
1157
1158
1158
:param msg: object to print
1159
1159
:param end: string appended after the end of the message, default a newline
1160
+ :param apply_style: If True, then ansi.style_output will be applied to the message text. Set to False in cases
1161
+ where the message text already has the desired style. Defaults to True.
1160
1162
"""
1161
1163
if not self .quiet :
1162
1164
if self .feedback_to_output :
1163
- self .poutput (msg , end = end )
1165
+ self .poutput (msg , end = end , apply_style = apply_style )
1164
1166
else :
1165
1167
self .perror (msg , end = end , apply_style = False )
1166
1168
1167
- def ppaged (self , msg : Any , * , end : str = '\n ' , chop : bool = False ) -> None :
1169
+ def ppaged (self , msg : Any , * , end : str = '\n ' , chop : bool = False , apply_style : bool = True ) -> None :
1168
1170
"""Print output using a pager if it would go off screen and stdout isn't currently being redirected.
1169
1171
1170
1172
Never uses a pager inside of a script (Python or text) or when output is being redirected or piped or when
@@ -1177,6 +1179,8 @@ def ppaged(self, msg: Any, *, end: str = '\n', chop: bool = False) -> None:
1177
1179
- chopping is ideal for displaying wide tabular data as is done in utilities like pgcli
1178
1180
False -> causes lines longer than the screen width to wrap to the next line
1179
1181
- wrapping is ideal when you want to keep users from having to use horizontal scrolling
1182
+ :param apply_style: If True, then ansi.style_output will be applied to the message text. Set to False in cases
1183
+ where the message text already has the desired style. Defaults to True.
1180
1184
1181
1185
WARNING: On Windows, the text always wraps regardless of what the chop argument is set to
1182
1186
"""
@@ -1215,7 +1219,7 @@ def ppaged(self, msg: Any, *, end: str = '\n', chop: bool = False) -> None:
1215
1219
pipe_proc = subprocess .Popen (pager , shell = True , stdin = subprocess .PIPE )
1216
1220
pipe_proc .communicate (msg_str .encode ('utf-8' , 'replace' ))
1217
1221
else :
1218
- self .poutput (msg_str , end = end )
1222
+ self .poutput (msg_str , end = end , apply_style = apply_style )
1219
1223
except BrokenPipeError :
1220
1224
# This occurs if a command's output is being piped to another process and that process closes before the
1221
1225
# command is finished. If you would like your application to print a warning message, then set the
0 commit comments