feat: add CLI carbon copy task query
This commit is contained in:
1 parent
1ef611eeab
commit
49b0359adb
5 files changed
+37
-6
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../types.js";
|
||||
import { numberOption, stringOption } from "../parser.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../parser.js";
|
||||
import { printJson, printTable } from "../printer.js";
|
||||
import { createEkbClient } from "../../core/auth/ekb.js";
|
||||
import { listTasks } from "../../domains/task/tools.js";
|
||||
@@ -23,16 +23,22 @@ export async function handleTaskCommand(parsed: CliParsedArgs, runtime: CliRunti
|
||||
? "approved"
|
||||
: action === "processed" || action === "records" || action === "history"
|
||||
? "processed"
|
||||
: action === "cc" || action === "carboncopy" || action === "carbon-copy"
|
||||
? "cc"
|
||||
: undefined;
|
||||
if (!view) {
|
||||
throw new Error("未知 task 子命令。支持: todo, approved, records (processed)");
|
||||
throw new Error("未知 task 子命令。支持: todo, approved, records, cc");
|
||||
}
|
||||
const count = numberOption(parsed.options, ["count", "limit", "n"], 20);
|
||||
const start = numberOption(parsed.options, ["start", "offset"], 0);
|
||||
const staffId = stringOption(parsed.options, ["staff", "staff-id", "staffId"]);
|
||||
const from = dateOption(stringOption(parsed.options, ["from", "start-date"]));
|
||||
const to = dateOption(stringOption(parsed.options, ["to", "end-date"]));
|
||||
const result = await listTasks(await createEkbClient(corp), corp.corpId || corp.id, view, { start, count, staffId, from, to });
|
||||
const read = booleanOption(parsed.options, ["read"]);
|
||||
const unread = booleanOption(parsed.options, ["unread"]);
|
||||
// Carbon copy defaults to unread, while the other views do not use this flag.
|
||||
const readFilter = view === "cc" ? read && !unread : undefined;
|
||||
const result = await listTasks(await createEkbClient(corp), corp.corpId || corp.id, view, { start, count, staffId, from, to, read: readFilter });
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
return { stdout: printJson({ corpId: corp.corpId || corp.id, corpName: corp.name, ...result }, runtime.outputOptions), stderr: "", exitCode: 0 };
|
||||
@@ -50,7 +56,7 @@ export async function handleTaskCommand(parsed: CliParsedArgs, runtime: CliRunti
|
||||
item.nodeName || "-",
|
||||
item.action || "-",
|
||||
]);
|
||||
const labels: Record<TaskView, string> = { todo: "待审批", approved: "已审批", processed: "审批记录" };
|
||||
const labels: Record<TaskView, string> = { todo: "待审批", approved: "已审批", processed: "审批记录", cc: readFilter ? "抄送(已读)" : "抄送(未读)" };
|
||||
return {
|
||||
stdout: `====== ${labels[view]}任务 (企业: ${corp.name} | 总数: ${result.total} | 当前返回: ${result.items.length}) ======\n${printTable(headers, rows)}\n`,
|
||||
stderr: "",
|
||||
|
||||
+2
-1
@@ -121,7 +121,7 @@ export function printHelp(): string {
|
||||
workflow 工作流管理 (list, get, find, toggle)
|
||||
bill 单据与费用明细检索 (list, get <单号|ID>, schema, link <单号|ID>)
|
||||
contact 企业通讯录与人员检索 (list, search <关键词>, get <staffId>)
|
||||
task 待办中心与审批任务 (todo, approved, records)
|
||||
task 待办中心与审批任务 (todo, approved, records, cc)
|
||||
platform 自建应用管理 (list)
|
||||
skill Agent Skill 管理 (install, status, dump)
|
||||
probe 连通性诊断 (probe [corpId])
|
||||
@@ -152,6 +152,7 @@ export function printHelp(): string {
|
||||
hose-use contact list --limit=20 # 采样查看企业通讯录(带防爆截断保护)
|
||||
hose-use task todo --json # 查看当前待我审批任务
|
||||
hose-use task approved # 查看我已审批任务
|
||||
hose-use task cc --unread # 查看未读抄送
|
||||
hose-use workflow list # 汇总查看全部工作流
|
||||
hose-use workflow find --task=code-js2 # 搜索包含自定义脚本的工作流
|
||||
hose-use bill list # 查看当前企业单据与报销列表
|
||||
|
||||
Reference in new issue
Block a user