( subcommand: string | undefined, args: string[], format: OutputFormat, )
| 8 | import { writeData, type OutputFormat } from "../lib/format.ts"; |
| 9 | |
| 10 | export function runTaskCommand( |
| 11 | subcommand: string | undefined, |
| 12 | args: string[], |
| 13 | format: OutputFormat, |
| 14 | ): number { |
| 15 | if (subcommand === "list") { |
| 16 | const queuedByIssueId = new Map(listQueuedTasksSync().map((task) => [task.issueId ?? "", task])); |
| 17 | writeData( |
| 18 | format, |
| 19 | listTasksSync().map((task) => { |
| 20 | const queued = queuedByIssueId.get(task.id); |
| 21 | return { |
| 22 | ...task, |
| 23 | queueStatus: queued?.status ?? "", |
| 24 | runtimeId: queued?.runtimeId ?? "", |
| 25 | }; |
| 26 | }), |
| 27 | ); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | if (subcommand === "create") { |
| 32 | const { flags } = parseArgs(args); |
| 33 | const title = getStringFlag(flags, "title"); |
| 34 | const channel = getStringFlag(flags, "channel"); |
| 35 | const assignee = getStringFlag(flags, "assignee"); |
| 36 | const priorityValue = getStringFlag(flags, "priority"); |
| 37 | const priority = priorityValue === "low" || priorityValue === "high" ? priorityValue : "medium"; |
| 38 | |
| 39 | if (!title || !channel || !assignee) { |
| 40 | console.error( |
| 41 | 'Usage: agent-space task create --title <title> --channel <name> --assignee <employee> [--priority low|medium|high] [--json]', |
| 42 | ); |
| 43 | return 1; |
| 44 | } |
| 45 | |
| 46 | const state = createTaskSync({ |
| 47 | title, |
| 48 | channel, |
| 49 | assignee, |
| 50 | priority, |
| 51 | }); |
| 52 | |
| 53 | writeData(format, { |
| 54 | ok: true, |
| 55 | title, |
| 56 | channel, |
| 57 | assignee, |
| 58 | priority, |
| 59 | totalTasks: state.tasks.length, |
| 60 | }); |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | if (subcommand === "inspect") { |
| 65 | const { flags } = parseArgs(args); |
| 66 | const id = getStringFlag(flags, "id"); |
| 67 |
no test coverage detected