From d4b470ca582e3c69c40438895b90748d44fc4653 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 25 Jun 2026 10:30:41 +0900 Subject: feat(cli): add --file flag to 'dispatch send' subcommand Add the same --file support that the summon (chat) command has to the 'dispatch send' subcommand. When --file is given, the file's contents are read and attached to the message (composed via composeMessage, identical to chat). - args.ts: add 'file' to the send ParsedCommand, make 'text' optional, parse --file, and require at least one of --text or --file. - main.ts: read the file and compose the message in the send case, using the composed message in both the --queue and streaming branches; update USAGE. - args.test.ts: cover --file parsing (alone, with --text, missing value) and update the existing send expectations + the both-missing error message. --- packages/cli/src/args.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'packages/cli/src/args.ts') diff --git a/packages/cli/src/args.ts b/packages/cli/src/args.ts index 8a63777..aaad2de 100644 --- a/packages/cli/src/args.ts +++ b/packages/cli/src/args.ts @@ -42,7 +42,8 @@ export type ParsedCommand = readonly kind: "send"; readonly server: string; readonly conversationId: string; - readonly text: string; + readonly text?: string | undefined; + readonly file?: string | undefined; readonly queue: boolean; readonly open: boolean; readonly cwd?: string; @@ -204,6 +205,7 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma let server = opts.defaultServer; let conversationId: string | undefined; let text: string | undefined; + let file: string | undefined; let queue = false; let open = false; let cwd: string | undefined; @@ -221,6 +223,10 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma if (i + 1 >= argv.length) return { kind: "error", message: "--text requires a value" }; text = argv[++i]; break; + case "--file": + if (i + 1 >= argv.length) return { kind: "error", message: "--file requires a value" }; + file = argv[++i]; + break; case "--queue": queue = true; break; @@ -263,8 +269,11 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma if (conversationId === undefined) { return { kind: "error", message: "'send' requires a conversation id" }; } - if (text === undefined) { - return { kind: "error", message: "'send' requires --text" }; + if (!text && !file) { + return { + kind: "error", + message: "At least one of --text or --file is required for 'send'", + }; } return { @@ -272,6 +281,7 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma server, conversationId, text, + file, queue, open, ...(cwd !== undefined && { cwd }), -- cgit v1.2.3