import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js"; import { handleList, handleGet, handleFind } from "./list.js"; import { handleToggle, handlePublish } from "./lifecycle.js"; import { handlePatch, handleSave } from "./draft.js"; import { handleHistory, handleLogs } from "./history.js"; import { handleJob } from "./job.js"; import { handleCheck } from "./check.js"; import { handleAnalyze } from "./analyze.js"; import { handleWorkflowDiff, handleWorkflowDiffJob } from "./diff.js"; export async function handleWorkflowCommand( parsed: CliParsedArgs, runtime: CliRuntime ): Promise { const currentCorp = runtime.selectedCorp; if (!currentCorp) { return { stdout: "", stderr: "未选中企业,请先通过 hose-use corps switch 或 --corp 指定企业\n", exitCode: 1, }; } const action = parsed.action || "list"; switch (action) { case "list": case "list-all": case "ls": return handleList(parsed, runtime); case "get": case "detail": case "info": return handleGet(parsed, runtime); case "find": case "search": return handleFind(parsed, runtime); case "toggle": return handleToggle(parsed, runtime); case "publish": case "enable": return handlePublish(parsed, runtime); case "save": case "update": return handleSave(parsed, runtime); case "patch": return handlePatch(parsed, runtime); case "history": case "snapshots": return handleHistory(parsed, runtime); case "logs": case "log": return handleLogs(parsed, runtime); case "job": case "execution": return handleJob(parsed, runtime); case "check": case "health": return handleCheck(parsed, runtime); case "analyze": case "analyse": return handleAnalyze(parsed, runtime); case "diff": case "diff-snapshot": case "diff-snapshots": case "compare": return handleWorkflowDiff(parsed, runtime); case "diff-job": case "diff-jobs": case "compare-job": return handleWorkflowDiffJob(parsed, runtime); default: return { stdout: "", stderr: `未知 workflow 子命令: ${action}。支持: list, get, find, analyze, toggle, publish, patch, save, history, logs, job, diff, diff-job, check\n`, exitCode: 1, }; } }