feat(mail): support positional message arg in reply command

Allow `gt mail reply <id> "message"` in addition to `-m` flag.
This is a desire-path fix - agents naturally try positional syntax.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beads/crew/collins
2026-01-21 17:28:47 -08:00
committed by beads/crew/emma
parent f00b0254f2
commit 6616a4726c
2 changed files with 18 additions and 5 deletions

View File

@@ -268,7 +268,7 @@ Examples:
}
var mailReplyCmd = &cobra.Command{
Use: "reply <message-id>",
Use: "reply <message-id> [message]",
Short: "Reply to a message",
Long: `Reply to a specific message.
@@ -277,10 +277,13 @@ This is a convenience command that automatically:
- Prefixes the subject with "Re: " (if not already present)
- Sends to the original sender
The message body can be provided as a positional argument or via -m flag.
Examples:
gt mail reply msg-abc123 "Thanks, working on it now"
gt mail reply msg-abc123 -m "Thanks, working on it now"
gt mail reply msg-abc123 -s "Custom subject" -m "Reply body"`,
Args: cobra.ExactArgs(1),
Args: cobra.RangeArgs(1, 2),
RunE: runMailReply,
}
@@ -457,8 +460,7 @@ func init() {
// Reply flags
mailReplyCmd.Flags().StringVarP(&mailReplySubject, "subject", "s", "", "Override reply subject (default: Re: <original>)")
mailReplyCmd.Flags().StringVarP(&mailReplyMessage, "message", "m", "", "Reply message body (required)")
_ = mailReplyCmd.MarkFlagRequired("message")
mailReplyCmd.Flags().StringVarP(&mailReplyMessage, "message", "m", "", "Reply message body")
// Search flags
mailSearchCmd.Flags().StringVar(&mailSearchFrom, "from", "", "Filter by sender address")

View File

@@ -82,6 +82,17 @@ func runMailThread(cmd *cobra.Command, args []string) error {
func runMailReply(cmd *cobra.Command, args []string) error {
msgID := args[0]
// Get message body from positional arg or flag (positional takes precedence)
messageBody := mailReplyMessage
if len(args) > 1 {
messageBody = args[1]
}
// Validate message is provided
if messageBody == "" {
return fmt.Errorf("message body required: provide as second argument or use -m flag")
}
// All mail uses town beads (two-level architecture)
workDir, err := findMailWorkDir()
if err != nil {
@@ -118,7 +129,7 @@ func runMailReply(cmd *cobra.Command, args []string) error {
From: from,
To: original.From, // Reply to sender
Subject: subject,
Body: mailReplyMessage,
Body: messageBody,
Type: mail.TypeReply,
Priority: mail.PriorityNormal,
ReplyTo: msgID,