From 63ec485c901afc611f57f49e9fa20539482be1db Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Fri, 27 Mar 2026 16:57:25 -0400 Subject: [PATCH] support "--width 0" for unlimited output Don't truncate lines with "..." at 333 chars. Co-Authored-By: Claude Opus 4.6 --- did/utils.py | 4 ++-- tests/unit/test_utils.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/did/utils.py b/did/utils.py index 16124e46..9aca2fc3 100644 --- a/did/utils.py +++ b/did/utils.py @@ -202,7 +202,7 @@ def shorted(text: str, width: int = MAX_WIDTH) -> str: lines = [] for line in text.split("\n"): - if len(line) <= width: + if width == 0 or len(line) <= width: lines.append(line) else: # Remove any word after first overlapping non-word character @@ -257,7 +257,7 @@ def item( if options.format == "wiki" and level == 0: indent = 1 # Shorten the text if necessary to match the desired maximum width - width = 333 + width = 0 if options is not None and options.width: width = options.width - indent - 2 spaces = " " * indent diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index da7743e7..6e999092 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -97,6 +97,20 @@ def test_shorted() -> None: assert res == "this...\nthis..." +def test_shorted_unlimited() -> None: + long_text = "this text is longer than 6\nthis is also longer" + res = did.utils.shorted(long_text, width=0) + assert res == long_text + + +def test_item_unlimited_width(capsys: pytest.CaptureFixture[str]) -> None: + options = Namespace(brief=False, format="text", width=0) + long_text = "x" * 500 + did.utils.item(long_text, level=0, options=options) + captured = capsys.readouterr() + assert captured.out == f"\n* {long_text}\n" + + def test_item_no_options(capsys: pytest.CaptureFixture[str]) -> None: did.utils.item("this is level 0 text", level=0, options=None) captured = capsys.readouterr()