From 2a71284d7df985b65f5faf27c6a54ed2fc584e6c Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Tue, 8 Sep 2026 04:10:02 -0400 Subject: [PATCH] A bare answer with nothing in it prints nothing, not a dash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit repeater-admin on a node that never answered, channels share on an empty slot: the bare form prints the value, and there is no value. A lone `-` there is a line of output where the exit status is the whole report — and 5 already means "ran fine, found nothing", which is the branch a script is waiting on. The document keeps the shape either way, with null where the answer would have been, because a consumer branching on it still needs the key. Co-Authored-By: Claude Opus 5 (1M context) --- meshterm/ui/renderers.py | 8 +++++++- tests/test_report.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/meshterm/ui/renderers.py b/meshterm/ui/renderers.py index cbb5d52..06d7a40 100644 --- a/meshterm/ui/renderers.py +++ b/meshterm/ui/renderers.py @@ -147,9 +147,15 @@ class PlainRenderer(Renderer): return None if block.shape == BARE: column = next(c for c in block.fields if c.key == block.bare) + value = block.values.get(column.key) + if value is None: + # The bare form prints the value, and there is no value: a node that never + # answered, a slot with nothing in it. A lone `-` there would be a line of + # output where the exit status is the whole report. + return None # As a Text, not a markup string: this is a private key, a share URL or a # remote node's own reply, and Rich would read a bracket in one as a style tag. - return Text(column.lanes[0].render(block.values.get(column.key))) + return Text(column.lanes[0].render(value)) rows: list[tuple[str, str]] = [] for column in block.fields: value = block.values.get(column.key) diff --git a/tests/test_report.py b/tests/test_report.py index 9906999..880163e 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -206,6 +206,24 @@ def test_a_get_prints_its_value_alone_and_still_documents_the_key() -> None: assert _json(block) == {"key": "tx_power", "value": "20", "type": "int"} +def test_a_bare_answer_with_nothing_in_it_prints_nothing_at_all() -> None: + """A node that never answered, a slot with nothing in it — and no lone dash. + + The bare form prints *the value*, so where there is none the exit status is the whole + report and stdout stays empty. The document still carries the shape, with ``null`` + where the answer would have been, because a consumer branching on it needs the key. + """ + block = Facts( + key="remote", + fields=(fields.word("command", "command"), fields.word("reply", "reply")), + values={"command": "get name", "reply": None}, + shape=BARE, + bare="reply", + ) + assert _plain(block) == "" + assert _json(block) == {"command": "get name", "reply": None} + + def test_an_acknowledgement_prints_nothing_and_is_still_a_document() -> None: """Printing nothing is an answer a person can act on and a program cannot.