feat(mail): Accept multiple message IDs in gt mail archive (#82)
Update the archive command to accept variadic arguments like bd close, allowing users to archive multiple messages in a single command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+33
-10
@@ -195,12 +195,16 @@ This closes the message in beads.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mailArchiveCmd = &cobra.Command{
|
var mailArchiveCmd = &cobra.Command{
|
||||||
Use: "archive <message-id>",
|
Use: "archive <message-id> [message-id...]",
|
||||||
Short: "Archive a message",
|
Short: "Archive messages",
|
||||||
Long: `Archive a message (alias for delete).
|
Long: `Archive one or more messages.
|
||||||
|
|
||||||
Removes the message from your inbox by closing it in beads.`,
|
Removes the messages from your inbox by closing them in beads.
|
||||||
Args: cobra.ExactArgs(1),
|
|
||||||
|
Examples:
|
||||||
|
gt mail archive hq-abc123
|
||||||
|
gt mail archive hq-abc123 hq-def456 hq-ghi789`,
|
||||||
|
Args: cobra.MinimumNArgs(1),
|
||||||
RunE: runMailArchive,
|
RunE: runMailArchive,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,8 +836,6 @@ func runMailDelete(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runMailArchive(cmd *cobra.Command, args []string) error {
|
func runMailArchive(cmd *cobra.Command, args []string) error {
|
||||||
msgID := args[0]
|
|
||||||
|
|
||||||
// Determine which inbox
|
// Determine which inbox
|
||||||
address := detectSender()
|
address := detectSender()
|
||||||
|
|
||||||
@@ -850,11 +852,32 @@ func runMailArchive(cmd *cobra.Command, args []string) error {
|
|||||||
return fmt.Errorf("getting mailbox: %w", err)
|
return fmt.Errorf("getting mailbox: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mailbox.Delete(msgID); err != nil {
|
// Archive all specified messages
|
||||||
return fmt.Errorf("archiving message: %w", err)
|
archived := 0
|
||||||
|
var errors []string
|
||||||
|
for _, msgID := range args {
|
||||||
|
if err := mailbox.Delete(msgID); err != nil {
|
||||||
|
errors = append(errors, fmt.Sprintf("%s: %v", msgID, err))
|
||||||
|
} else {
|
||||||
|
archived++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("%s Message archived\n", style.Bold.Render("✓"))
|
// Report results
|
||||||
|
if len(errors) > 0 {
|
||||||
|
fmt.Printf("%s Archived %d/%d messages\n",
|
||||||
|
style.Bold.Render("⚠"), archived, len(args))
|
||||||
|
for _, e := range errors {
|
||||||
|
fmt.Printf(" Error: %s\n", e)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("failed to archive %d messages", len(errors))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) == 1 {
|
||||||
|
fmt.Printf("%s Message archived\n", style.Bold.Render("✓"))
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s Archived %d messages\n", style.Bold.Render("✓"), archived)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user