A bare answer with nothing in it prints nothing, not a dash

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) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-09-08 04:10:02 -04:00
1 parent 8d2a7b8281
commit 2a71284d7d
2 files changed
+25 -1

No files matched your search

+7 -1
View File
@@ -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)
+18
View File
@@ -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.