cmdlet refactor
This commit is contained in:
@@ -224,7 +224,7 @@ class TagEditorPopup(ModalScreen[None]):
|
||||
if not tags:
|
||||
try:
|
||||
runner: PipelineRunner = getattr(app, "executor")
|
||||
cmd = "@1 | get-tag"
|
||||
cmd = "@1 | metadata -get"
|
||||
res = runner.run_pipeline(cmd, seeds=self._seeds, isolate=True)
|
||||
tags = _extract_tag_names_from_table(getattr(res, "result_table", None))
|
||||
if not tags:
|
||||
@@ -364,10 +364,10 @@ class TagEditorPopup(ModalScreen[None]):
|
||||
|
||||
if to_del:
|
||||
del_args = " ".join(json.dumps(t) for t in to_del)
|
||||
del_cmd = f"delete-tag -instance {store_tok}{query_chunk} {del_args}"
|
||||
_log_pipeline_command("delete-tag", del_cmd)
|
||||
del_cmd = f"metadata -delete -instance {store_tok}{query_chunk} {del_args}"
|
||||
_log_pipeline_command("metadata-delete", del_cmd)
|
||||
del_res = runner.run_pipeline(del_cmd, seeds=self._seeds, isolate=True)
|
||||
_log_pipeline_result("delete-tag", del_res)
|
||||
_log_pipeline_result("metadata-delete", del_res)
|
||||
if not getattr(del_res, "success", False):
|
||||
failures.append(
|
||||
str(
|
||||
@@ -375,16 +375,16 @@ class TagEditorPopup(ModalScreen[None]):
|
||||
"error",
|
||||
"") or getattr(del_res,
|
||||
"stderr",
|
||||
"") or "delete-tag failed"
|
||||
"") or "metadata -delete failed"
|
||||
).strip()
|
||||
)
|
||||
|
||||
if to_add:
|
||||
add_args = " ".join(json.dumps(t) for t in to_add)
|
||||
add_cmd = f"add-tag -instance {store_tok}{query_chunk} {add_args}"
|
||||
_log_pipeline_command("add-tag", add_cmd)
|
||||
add_cmd = f"metadata -add -instance {store_tok}{query_chunk} {add_args}"
|
||||
_log_pipeline_command("metadata-add", add_cmd)
|
||||
add_res = runner.run_pipeline(add_cmd, seeds=self._seeds, isolate=True)
|
||||
_log_pipeline_result("add-tag", add_res)
|
||||
_log_pipeline_result("metadata-add", add_res)
|
||||
if not getattr(add_res, "success", False):
|
||||
failures.append(
|
||||
str(
|
||||
@@ -392,7 +392,7 @@ class TagEditorPopup(ModalScreen[None]):
|
||||
"error",
|
||||
"") or getattr(add_res,
|
||||
"stderr",
|
||||
"") or "add-tag failed"
|
||||
"") or "metadata -add failed"
|
||||
).strip()
|
||||
)
|
||||
|
||||
@@ -1027,8 +1027,8 @@ class PipelineHubApp(App):
|
||||
"""Apply store/path/tags UI fields to the pipeline text.
|
||||
|
||||
Rules (simple + non-destructive):
|
||||
- If output path is set and the first stage is download-file and has no -path/--path, append -path.
|
||||
- If an instance is selected and pipeline has no add-file stage, append add-file -instance <name>.
|
||||
- If output path is set and the first stage is file-download and has no -path/--path, append -path.
|
||||
- If an instance is selected and pipeline has no file-add stage, append file -add -instance <name>.
|
||||
"""
|
||||
base = str(pipeline_text or "").strip()
|
||||
if not base:
|
||||
@@ -1058,29 +1058,28 @@ class PipelineHubApp(App):
|
||||
except Exception:
|
||||
first_stage_cmd = ""
|
||||
|
||||
# Apply -path to download-file first stage (only if missing)
|
||||
# Apply -path to file-download first stage (only if missing)
|
||||
if output_path:
|
||||
first = stages[0]
|
||||
low = first.lower()
|
||||
if low.startswith("download-file"
|
||||
) and " -path" not in low and " --path" not in low:
|
||||
if (low.startswith("download-file") or (low.startswith("file ") and " -download" in low)) and " -path" not in low and " --path" not in low:
|
||||
stages[0] = f"{first} -path {json.dumps(output_path)}"
|
||||
|
||||
joined = " | ".join(stages)
|
||||
|
||||
low_joined = joined.lower()
|
||||
|
||||
# Only auto-append add-file for download pipelines.
|
||||
# Only auto-append file -add for download pipelines.
|
||||
should_auto_add_file = bool(
|
||||
selected_store and ("add-file" not in low_joined) and (
|
||||
first_stage_cmd
|
||||
in {"download-file"}
|
||||
selected_store and ("add-file" not in low_joined and "file -add" not in low_joined) and (
|
||||
first_stage_cmd in {"download-file"}
|
||||
or (first_stage_cmd == "file" and " -download" in stages[0].lower())
|
||||
)
|
||||
)
|
||||
|
||||
if should_auto_add_file:
|
||||
store_token = json.dumps(selected_store)
|
||||
joined = f"{joined} | add-file -instance {store_token}"
|
||||
joined = f"{joined} | file -add -instance {store_token}"
|
||||
|
||||
return joined
|
||||
|
||||
@@ -1092,13 +1091,13 @@ class PipelineHubApp(App):
|
||||
return command
|
||||
|
||||
low = command.lower()
|
||||
if "add-tag" in low:
|
||||
# User already controls tag stage explicitly.
|
||||
if "metadata -add" in low:
|
||||
# User already controls metadata tag stage explicitly.
|
||||
self._pending_pipeline_tags_applied = False
|
||||
return command
|
||||
|
||||
# Apply draft tags when pipeline stores/emits files via add-file.
|
||||
if "add-file" not in low:
|
||||
# Apply draft tags when pipeline stores/emits files via file-add.
|
||||
if "add-file" not in low and "file -add" not in low:
|
||||
self._pending_pipeline_tags_applied = False
|
||||
return command
|
||||
|
||||
@@ -1109,7 +1108,7 @@ class PipelineHubApp(App):
|
||||
|
||||
self._pending_pipeline_tags_applied = True
|
||||
self.notify(f"Applying {len(pending)} pending tag(s) after pipeline", timeout=3)
|
||||
return f"{command} | add-tag {tag_args}"
|
||||
return f"{command} | metadata -add {tag_args}"
|
||||
|
||||
def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None:
|
||||
if not self.results_table or event.control is not self.results_table:
|
||||
@@ -1656,27 +1655,27 @@ class PipelineHubApp(App):
|
||||
try:
|
||||
if to_del:
|
||||
del_args = " ".join(json.dumps(t) for t in to_del)
|
||||
del_cmd = f"delete-tag -instance {store_tok}{query_chunk} {del_args}"
|
||||
del_cmd = f"metadata -delete -instance {store_tok}{query_chunk} {del_args}"
|
||||
del_res = runner.run_pipeline(del_cmd, seeds=seeds, isolate=True)
|
||||
if not getattr(del_res, "success", False):
|
||||
failures.append(
|
||||
str(
|
||||
getattr(del_res, "error", "")
|
||||
or getattr(del_res, "stderr", "")
|
||||
or "delete-tag failed"
|
||||
or "metadata -delete failed"
|
||||
).strip()
|
||||
)
|
||||
|
||||
if to_add:
|
||||
add_args = " ".join(json.dumps(t) for t in to_add)
|
||||
add_cmd = f"add-tag -instance {store_tok}{query_chunk} {add_args}"
|
||||
add_cmd = f"metadata -add -instance {store_tok}{query_chunk} {add_args}"
|
||||
add_res = runner.run_pipeline(add_cmd, seeds=seeds, isolate=True)
|
||||
if not getattr(add_res, "success", False):
|
||||
failures.append(
|
||||
str(
|
||||
getattr(add_res, "error", "")
|
||||
or getattr(add_res, "stderr", "")
|
||||
or "add-tag failed"
|
||||
or "metadata -add failed"
|
||||
).strip()
|
||||
)
|
||||
|
||||
@@ -1835,7 +1834,7 @@ class PipelineHubApp(App):
|
||||
if not store_name or not file_hash:
|
||||
return
|
||||
try:
|
||||
from cmdlet.get_tag import _emit_tags_as_table
|
||||
from cmdlet.metadata.tag_get import _emit_tags_as_table
|
||||
except Exception:
|
||||
return
|
||||
|
||||
@@ -2358,7 +2357,7 @@ class PipelineHubApp(App):
|
||||
self.notify("Delete action requires store + hash", severity="warning", timeout=3)
|
||||
return
|
||||
query = f"hash:{hash_value}"
|
||||
cmd = f"delete-file -instance {json.dumps(store_name)} -query {json.dumps(query)}"
|
||||
cmd = f"file -delete -instance {json.dumps(store_name)} -query {json.dumps(query)}"
|
||||
self._start_pipeline_execution(cmd)
|
||||
return
|
||||
|
||||
@@ -2398,11 +2397,11 @@ class PipelineHubApp(App):
|
||||
|
||||
query = f"hash:{hash_value}"
|
||||
base_copy = (
|
||||
f"search-file -instance {json.dumps(store_name)} {json.dumps(query)}"
|
||||
f" | add-file -instance {json.dumps(selected_store)}"
|
||||
f"file -search -instance {json.dumps(store_name)} {json.dumps(query)}"
|
||||
f" | file -add -instance {json.dumps(selected_store)}"
|
||||
)
|
||||
if action == "move_to_selected_store":
|
||||
delete_cmd = f"delete-file -instance {json.dumps(store_name)} -query {json.dumps(query)}"
|
||||
delete_cmd = f"file -delete -instance {json.dumps(store_name)} -query {json.dumps(query)}"
|
||||
cmd = f"{base_copy} | @ | {delete_cmd}"
|
||||
else:
|
||||
cmd = base_copy
|
||||
|
||||
Reference in New Issue
Block a user