This commit is contained in:
2025-12-31 05:17:37 -08:00
parent 3bbaa28fb4
commit e8842ceded
10 changed files with 1255 additions and 29 deletions

View File

@@ -1,12 +1,13 @@
from __future__ import annotations
from pathlib import Path
from typing import Any, Dict, Optional, Sequence
from typing import Any, Dict, List, Optional, Sequence
import sys
from SYS.logger import log
from SYS import pipeline as ctx
from SYS.result_table import ResultTable
from . import _shared as sh
Cmdlet = sh.Cmdlet
@@ -99,6 +100,8 @@ class Get_Note(Cmdlet):
store_registry = Store(config)
any_notes = False
display_items: List[Dict[str, Any]] = []
note_table: Optional[ResultTable] = None
for res in results:
if not isinstance(res, dict):
@@ -145,6 +148,13 @@ class Get_Note(Cmdlet):
continue
any_notes = True
if note_table is None:
note_table = (
ResultTable("note")
.set_table("note")
.set_value_case("preserve")
.set_preserve_order(True)
)
# Emit each note as its own row so CLI renders a proper note table
for k in sorted(notes.keys(), key=lambda x: str(x).lower()):
v = notes.get(k)
@@ -152,23 +162,27 @@ class Get_Note(Cmdlet):
# Keep payload small for IPC/pipes.
raw_text = raw_text[:999]
preview = " ".join(raw_text.replace("\r", "").split("\n"))
ctx.emit(
{
"store": store_name,
"hash": resolved_hash,
"note_name": str(k),
"note_text": raw_text,
"columns": [
("Name",
str(k)),
("Text",
preview.strip()),
],
}
)
payload: Dict[str, Any] = {
"store": store_name,
"hash": resolved_hash,
"note_name": str(k),
"note_text": raw_text,
"columns": [
("Name",
str(k)),
("Text",
preview.strip()),
],
}
display_items.append(payload)
if note_table is not None:
note_table.add_result(payload)
ctx.emit(payload)
if not any_notes:
ctx.emit("No notes found.")
elif note_table is not None:
ctx.set_last_result_table(note_table, display_items, subject=result)
return 0