Skip to content

Commit c07f5dc

Browse files
committed
Disabled automatic detection for markup, emoji, and highlighting
in Cmd2RichArgparseConsole.
1 parent b093bc9 commit c07f5dc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

cmd2/rich_utils.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __init__(self, file: IO[str] | None = None) -> None:
183183
Defaults to sys.stdout.
184184
"""
185185
# This console is configured for general-purpose printing. It enables soft wrap
186-
# and disables Rich's automatic processing for markup, emoji, and highlighting.
186+
# and disables Rich's automatic detection for markup, emoji, and highlighting.
187187
# These defaults can be overridden in calls to the console's or cmd2's print methods.
188188
super().__init__(
189189
file=file,
@@ -201,6 +201,22 @@ class Cmd2RichArgparseConsole(Cmd2BaseConsole):
201201
which conflicts with rich-argparse's explicit no_wrap and overflow settings.
202202
"""
203203

204+
def __init__(self, file: IO[str] | None = None) -> None:
205+
"""Cmd2RichArgparseConsole initializer.
206+
207+
:param file: optional file object where the console should write to.
208+
Defaults to sys.stdout.
209+
"""
210+
# Disable Rich's automatic detection for markup, emoji, and highlighting.
211+
# rich-argparse does markup and highlighting without involving the console
212+
# so these won't affect its internal functionality.
213+
super().__init__(
214+
file=file,
215+
markup=False,
216+
emoji=False,
217+
highlight=False,
218+
)
219+
204220

205221
class Cmd2ExceptionConsole(Cmd2BaseConsole):
206222
"""Rich console for printing exceptions.

0 commit comments

Comments
 (0)