Skip to content

Commit f5f699d

Browse files
plossonclaude
andcommitted
fix(gmail): treat --body - as read-from-stdin sentinel
Passing `--body -` set the body to the literal "-" because parseBody only fell back to stdin when --body was entirely absent. Piping a heredoc through `--body -` therefore lost the message body. Now a bare "-" is treated as an explicit stdin sentinel, matching the common CLI convention. Applies to both `gmail send` and `gmail draft` (shared parseBody). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5bf1fac commit f5f699d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/commands/gmail.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ function addComposeOptions(cmd: Command): Command {
2121
.option('--cc <email>', 'CC recipient (repeatable)', (val: string, acc: string[]) => [...acc, val], [])
2222
.option('--bcc <email>', 'BCC recipient (repeatable)', (val: string, acc: string[]) => [...acc, val], [])
2323
.option('--subject <subject>', 'Email subject (required unless --reply-to)')
24-
.option('--body <body>', 'Email body (or pipe via stdin)')
24+
.option('--body <body>', 'Email body (omit or pass "-" to read from stdin)')
2525
.option('--html', 'Treat body as HTML')
2626
.option('--reply-to <thread-id>', 'Thread ID to reply to (derives to/subject from thread)')
2727
.option('--attachment <path>', 'File to attach (repeatable)', (val: string, acc: string[]) => [...acc, val], [])
2828
.option('--inline <cid:path>', 'Inline image (repeatable, format: contentId:filepath). Supports PNG, JPG, GIF only (not SVG)', (val: string, acc: string[]) => [...acc, val], []);
2929
}
3030

3131
async function parseBody(body: string | undefined): Promise<string> {
32-
if (!body) {
32+
// Treat a bare "-" as an explicit "read from stdin" sentinel, matching the
33+
// common CLI convention (otherwise the literal "-" would be sent as the body).
34+
if (!body || body === '-') {
3335
body = await readStdin() ?? undefined;
3436
}
3537
if (!body) {

0 commit comments

Comments
 (0)