summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/args.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-25 10:30:41 +0900
committerAdam Malczewski <[email protected]>2026-06-25 10:30:41 +0900
commitd4b470ca582e3c69c40438895b90748d44fc4653 (patch)
tree1556ec4073013cec8d5599a6aa9911bedcfca7c3 /packages/cli/src/args.ts
parent8a74335c21a57ee63c9a0658754430d6520dbc87 (diff)
downloaddispatch-d4b470ca582e3c69c40438895b90748d44fc4653.tar.gz
dispatch-d4b470ca582e3c69c40438895b90748d44fc4653.zip
feat(cli): add --file flag to 'dispatch send' subcommand
Add the same --file <path> 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.
Diffstat (limited to 'packages/cli/src/args.ts')
-rw-r--r--packages/cli/src/args.ts16
1 files changed, 13 insertions, 3 deletions
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 }),