Files
hose-use/src/cli/commands/platform/index.ts
T

56 lines
2.1 KiB
TypeScript

import { booleanOption } from "../../parser.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
import { handleList, handleGet, handleEntities, handleSchema, handlePermissions, handleImports } from "./app-info.js";
import { handleRecords, handleAudit } from "./records.js";
import { handleRecordAction } from "./record-actions.js";
export async function handlePlatformCommand(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
if (!runtime.selectedCorp) {
return { stdout: "", stderr: "未选中企业,请先通过 hose-use corps switch 或 --corp 指定企业\n", exitCode: 1 };
}
const action = parsed.action || "list";
const isWorkbench = action === "workbench" || booleanOption(parsed.options, ["workbench", "w"], false);
if (isWorkbench) {
const { handleAppCommand } = await import("./../app.js");
return handleAppCommand(parsed, runtime);
}
switch (action) {
case "list":
case "ls":
case "apps": return handleList(parsed, runtime);
case "get":
case "show": return handleGet(parsed, runtime);
case "entities":
case "objects": return handleEntities(parsed, runtime);
case "schema":
case "fields": return handleSchema(parsed, runtime);
case "records":
case "data":
case "search":
case "stats":
case "profile": return handleRecords(parsed, runtime);
case "audit":
case "check":
case "health": return handleAudit(parsed, runtime);
case "record":
case "record-get":
case "record-toggle":
case "record-edit":
case "record-batch-edit":
case "batch-edit":
case "record-update":
case "update":
case "batch-update":
case "record-recompute": return handleRecordAction(parsed, runtime);
case "permissions":
case "permission":
case "auth": return handlePermissions(parsed, runtime);
case "imports":
case "import-jobs": return handleImports(parsed, runtime);
default:
return { stdout: "", stderr: `未知 platform 子命令: ${action}。支持: list, get, entities, schema, records, audit, record, permissions, imports\n`, exitCode: 1 };
}
}