update
This commit is contained in:
+872
-120
File diff suppressed because it is too large
Load Diff
+15
-10
@@ -553,13 +553,26 @@ class Add_Tag(Cmdlet):
|
||||
extract_debug = bool(parsed.get("extract-debug", False))
|
||||
extract_debug_rx, extract_debug_err = _try_compile_extract_template(extract_template)
|
||||
|
||||
raw_tag = parsed.get("tag", [])
|
||||
if isinstance(raw_tag, str):
|
||||
raw_tag = [raw_tag]
|
||||
|
||||
# Normalize input early so a non-hash -query can be treated as the tag payload
|
||||
# when the target item is already coming from the pipeline.
|
||||
results = normalize_result_input(result)
|
||||
|
||||
query_value = parsed.get("query")
|
||||
query_hash, query_valid = sh.require_single_hash_query(
|
||||
parsed.get("query"),
|
||||
query_value,
|
||||
"[add_tag] Error: -query must be of the form hash:<sha256>",
|
||||
log_file=sys.stderr,
|
||||
)
|
||||
if not query_valid:
|
||||
return 1
|
||||
if not raw_tag and results and query_value:
|
||||
raw_tag = [str(query_value)]
|
||||
query_hash = None
|
||||
else:
|
||||
return 1
|
||||
|
||||
hash_override = query_hash
|
||||
|
||||
@@ -581,9 +594,6 @@ class Add_Tag(Cmdlet):
|
||||
if has_downstream and not include_temp and not store_override:
|
||||
include_temp = True
|
||||
|
||||
# Normalize input to list
|
||||
results = normalize_result_input(result)
|
||||
|
||||
# Filter by temp status (unless --all is set)
|
||||
if not include_temp:
|
||||
results = filter_results_by_temp(results, include_temp=False)
|
||||
@@ -599,11 +609,6 @@ class Add_Tag(Cmdlet):
|
||||
)
|
||||
return 1
|
||||
|
||||
# Get tag from arguments (or fallback to pipeline payload)
|
||||
raw_tag = parsed.get("tag", [])
|
||||
if isinstance(raw_tag, str):
|
||||
raw_tag = [raw_tag]
|
||||
|
||||
# Fallback: if no tag provided explicitly, try to pull from first result payload.
|
||||
# IMPORTANT: when -extract is used, users typically want *only* extracted tags,
|
||||
# not "re-add whatever tags are already in the payload".
|
||||
|
||||
@@ -462,13 +462,23 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
rest.append(a)
|
||||
i += 1
|
||||
|
||||
# Normalize the incoming target list early so a non-hash -query can be treated
|
||||
# as the delete-tag payload when the file target already comes from the pipeline.
|
||||
items_to_process = sh.normalize_result_items(result)
|
||||
tags_arg = _parse_delete_tag_arguments(rest)
|
||||
|
||||
override_hash, query_valid = sh.require_single_hash_query(
|
||||
override_query,
|
||||
"Invalid -query value (expected hash:<sha256>)",
|
||||
log_file=sys.stderr,
|
||||
)
|
||||
if not query_valid:
|
||||
return 1
|
||||
if (not tags_arg and override_query and items_to_process and not has_piped_tag
|
||||
and not has_piped_tag_list):
|
||||
tags_arg = _parse_delete_tag_arguments([override_query])
|
||||
override_hash = None
|
||||
else:
|
||||
return 1
|
||||
|
||||
# Selection syntax (@...) is handled by the pipeline runner, not by this cmdlet.
|
||||
# If @ reaches here as a literal argument, it's almost certainly user error.
|
||||
@@ -485,7 +495,6 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
except Exception:
|
||||
grouped_table = ""
|
||||
grouped_tags = get_field(result, "tag") if result is not None else None
|
||||
tags_arg = _parse_delete_tag_arguments(rest)
|
||||
if (grouped_table == "tag.selection" and isinstance(grouped_tags,
|
||||
list) and grouped_tags
|
||||
and not tags_arg):
|
||||
@@ -503,9 +512,6 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
log("Requires at least one tag argument")
|
||||
return 1
|
||||
|
||||
# Normalize result to a list for processing
|
||||
items_to_process = sh.normalize_result_items(result)
|
||||
|
||||
# Process each item
|
||||
success_count = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user