import type { Command } from "commander"; import { getClient, parseKvPairs } from "../context.ts"; import { rootOpts, run } from "./run.ts"; export function registerListCommands(program: Command): void { const lists = program.command("lists").description("List (column) operations"); lists.command("get ").action((id, _opts, cmd) => run(cmd, async () => { const { client } = getClient(rootOpts(cmd).profile); return client.listGet(id); }), ); lists .command("create") .requiredOption("--board ", "Board id") .requiredOption("--name ", "List name") .option("--pos ", "Position") .action((opts, cmd) => run(cmd, async () => { const { client } = getClient(rootOpts(cmd).profile); return client.listCreate({ idBoard: opts.board, name: opts.name, pos: opts.pos, }); }), ); lists .command("update ") .option("--params ", "key=value params") .action((id, opts, cmd) => run(cmd, async () => { const { client } = getClient(rootOpts(cmd).profile); return client.listUpdate(id, parseKvPairs(opts.params)); }), ); lists.command("archive ").action((id, _opts, cmd) => run(cmd, async () => { const { client } = getClient(rootOpts(cmd).profile); return client.listArchive(id); }), ); lists.command("cards ").action((id, _opts, cmd) => run(cmd, async () => { const { client } = getClient(rootOpts(cmd).profile); return client.listCards(id); }), ); }