dfd
This commit is contained in:
55
CLI.py
55
CLI.py
@@ -1112,6 +1112,28 @@ def _execute_pipeline(tokens: list):
|
||||
|
||||
cmd_name = stage_tokens[0].replace("_", "-").lower()
|
||||
stage_args = stage_tokens[1:]
|
||||
|
||||
# Bare '@' means "use the subject for the current result table" (e.g., the file whose tags/URLs are shown)
|
||||
if cmd_name == "@":
|
||||
subject = ctx.get_last_result_subject()
|
||||
if subject is None:
|
||||
print("No current result context available for '@'\n")
|
||||
pipeline_status = "failed"
|
||||
pipeline_error = "No result subject for @"
|
||||
return
|
||||
# Normalize to list for downstream expectations
|
||||
piped_result = subject
|
||||
try:
|
||||
subject_items = subject if isinstance(subject, list) else [subject]
|
||||
ctx.set_last_items(subject_items)
|
||||
except Exception:
|
||||
pass
|
||||
if pipeline_session and worker_manager:
|
||||
try:
|
||||
worker_manager.log_step(pipeline_session.worker_id, "@ used current table subject")
|
||||
except Exception:
|
||||
pass
|
||||
continue
|
||||
|
||||
# Check if this is a selection syntax (@N, @N-M, @{N,M,K}, @*, @3,5,7, @3-6,8) instead of a command
|
||||
if cmd_name.startswith('@'):
|
||||
@@ -1280,8 +1302,11 @@ def _execute_pipeline(tokens: list):
|
||||
}
|
||||
# Commands that manage their own table/history state (e.g. get-tag)
|
||||
self_managing_commands = {
|
||||
'get-tag', 'get_tag', 'tags'
|
||||
'get-tag', 'get_tag', 'tags',
|
||||
'search-file', 'search_file'
|
||||
}
|
||||
|
||||
overlay_table = ctx.get_display_table() if hasattr(ctx, 'get_display_table') else None
|
||||
|
||||
if cmd_name in self_managing_commands:
|
||||
# Command has already set the table and history
|
||||
@@ -1302,22 +1327,28 @@ def _execute_pipeline(tokens: list):
|
||||
for emitted in pipeline_ctx.emits:
|
||||
table.add_result(emitted)
|
||||
else:
|
||||
table = ResultTable(table_title)
|
||||
for emitted in pipeline_ctx.emits:
|
||||
table.add_result(emitted)
|
||||
|
||||
if cmd_name in selectable_commands:
|
||||
table = ResultTable(table_title)
|
||||
for emitted in pipeline_ctx.emits:
|
||||
table.add_result(emitted)
|
||||
table.set_source_command(cmd_name, stage_args)
|
||||
ctx.set_last_result_table(table, pipeline_ctx.emits)
|
||||
elif cmd_name in display_only_commands:
|
||||
table = ResultTable(table_title)
|
||||
for emitted in pipeline_ctx.emits:
|
||||
table.add_result(emitted)
|
||||
# Display-only: show table but preserve search context
|
||||
ctx.set_last_result_items_only(pipeline_ctx.emits)
|
||||
else:
|
||||
# Action commands (add-*, delete-*): update items only, don't change table/history
|
||||
ctx.set_last_result_items_only(pipeline_ctx.emits)
|
||||
# Action commands: avoid overwriting search history/table unless a display overlay exists
|
||||
if overlay_table is not None:
|
||||
table = overlay_table
|
||||
else:
|
||||
table = None
|
||||
|
||||
print()
|
||||
print(table.format_plain())
|
||||
if table is not None:
|
||||
print()
|
||||
print(table.format_plain())
|
||||
else:
|
||||
for emitted in pipeline_ctx.emits:
|
||||
if isinstance(emitted, dict):
|
||||
@@ -1518,7 +1549,8 @@ def _execute_cmdlet(cmd_name: str, args: list):
|
||||
}
|
||||
# Commands that manage their own table/history state (e.g. get-tag)
|
||||
self_managing_commands = {
|
||||
'get-tag', 'get_tag', 'tags'
|
||||
'get-tag', 'get_tag', 'tags',
|
||||
'search-file', 'search_file'
|
||||
}
|
||||
|
||||
if cmd_name in self_managing_commands:
|
||||
@@ -1574,7 +1606,8 @@ def _execute_cmdlet(cmd_name: str, args: list):
|
||||
'check-file-status', 'check_file_status'
|
||||
}
|
||||
self_managing_commands = {
|
||||
'get-tag', 'get_tag', 'tags'
|
||||
'get-tag', 'get_tag', 'tags',
|
||||
'search-file', 'search_file'
|
||||
}
|
||||
|
||||
if cmd_name in self_managing_commands:
|
||||
|
||||
Reference in New Issue
Block a user