This commit is contained in:
2026-01-12 20:01:45 -08:00
parent be55e6e450
commit 2870abf4de
7 changed files with 2083 additions and 52 deletions

View File

@@ -669,17 +669,34 @@ class Add_Tag(Cmdlet):
# treat add-tag as a pipeline mutation (carry tags forward for add-file) instead of a store write.
if not store_override:
store_name_str = str(store_name) if store_name is not None else ""
local_mode_requested = (
(not store_name_str) or (store_name_str.upper() == "PATH")
or (store_name_str.lower() == "local")
)
is_known_backend = bool(store_name_str) and store_registry.is_available(
store_name_str
)
is_known_backend = False
try:
is_known_backend = bool(store_name_str) and store_registry.is_available(
store_name_str
)
except Exception:
pass
if local_mode_requested and raw_path:
# If the item isn't in a configured store backend yet (e.g., store=PATH),
# treat add-tag as a pipeline mutation (carry tags forward for add-file)
# instead of a store write.
if not is_known_backend:
try:
if Path(str(raw_path)).expanduser().exists():
# We allow metadata updates even if file doesn't exist locally,
# but check path existence if valid path provided.
proceed_local = True
if raw_path:
try:
if not Path(str(raw_path)).expanduser().exists():
# If path is provided but missing, we might prefer skipping?
# But for pipeline metadata, purely missing file shouldn't block tagging.
# So we allow it.
pass
except Exception:
pass
if proceed_local:
existing_tag_list = _extract_item_tags(res)
existing_lower = {
t.lower()
@@ -799,14 +816,9 @@ class Add_Tag(Cmdlet):
except Exception:
pass
if local_mode_requested:
log(
"[add_tag] Error: Missing usable local path for tagging (or provide -store)",
file=sys.stderr,
)
return 1
if store_name_str and not is_known_backend:
# If it's not a known backend and we didn't handle it above as a local/pipeline
# metadata edit, then it's an error.
log(
f"[add_tag] Error: Unknown store '{store_name_str}'. Available: {store_registry.list_backends()}",
file=sys.stderr,

View File

@@ -514,7 +514,19 @@ def _run(result: Any, _args: Sequence[str], config: Dict[str, Any]) -> int:
return 0
# Display results
table = ResultTable(f"Relationships: {source_title}"
from SYS.result_table import ItemDetailView, extract_item_metadata
# Prepare metadata for the detail view
metadata = extract_item_metadata(result)
if hash_hex:
metadata["Hash"] = hash_hex
# Overlays
if source_title and source_title != "Unknown":
metadata["Title"] = source_title
table = ItemDetailView(f"Relationships", item_metadata=metadata
).init_command("get-relationship",
[])

View File

@@ -322,15 +322,23 @@ def _emit_tags_as_table(
This replaces _print_tag_list to make tags pipe-able.
Stores the table via ctx.set_last_result_table_overlay (or ctx.set_last_result_table) for downstream @ selection.
"""
from SYS.result_table import ResultTable
from SYS.result_table import ItemDetailView, extract_item_metadata
# Create ResultTable with just tag column (no title)
# Keep the title stable and avoid including hash fragments.
table_title = "tag"
# Prepare metadata for the detail view
metadata = extract_item_metadata(subject)
# Overlays/Overrides from explicit args if subject was partial
if item_title:
table_title = f"tag: {item_title}"
metadata["Title"] = item_title
if file_hash:
metadata["Hash"] = file_hash
if store:
metadata["Store"] = service_name if service_name else store
if path:
metadata["Path"] = path
table = ResultTable(table_title, max_columns=1)
# Create ItemDetailView
table = ItemDetailView("Tags", item_metadata=metadata, max_columns=1)
table.set_source_command("get-tag", [])
# Create TagItem for each tag

View File

@@ -421,14 +421,20 @@ class Get_Url(Cmdlet):
from SYS.metadata import normalize_urls
urls = normalize_urls(urls)
title = str(get_field(result, "title") or "").strip()
table_title = "Title"
if title:
table_title = f"Title: {title}"
from SYS.result_table import ItemDetailView, extract_item_metadata
# Prepare metadata for the detail view
metadata = extract_item_metadata(result)
if file_hash:
metadata["Hash"] = file_hash
if store_name:
metadata["Store"] = store_name
table = (
ResultTable(
table_title,
ItemDetailView(
"Urls",
item_metadata=metadata,
max_columns=1
).set_preserve_order(True).set_table("url").set_value_case("preserve")
)