refactor(cli): split commands/workflow.ts into directory form (list/lifecycle/draft/history/job/check/analyze)
Verbatim code moves; drops dead WORKFLOW_STATE_DIR const that was declared but never read. No behavior change: tsc clean, 316 tests pass.
This commit is contained in:
1 parent
52342a9b8e
commit
6f1f2623a3
11 files changed
+1034
-983
No files matched your search
@@ -0,0 +1,69 @@
|
||||
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";
|
||||
|
||||
export async function handleWorkflowCommand(
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
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);
|
||||
default:
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `未知 workflow 子命令: ${action}。支持: list, get, find, analyze, toggle, publish, patch, save, history, logs, job, check\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user