From d610d444d78cf03f8e6f824d84380ff3d53e5bf9 Mon Sep 17 00:00:00 2001 From: dementus Date: Tue, 20 Jan 2026 20:37:19 -0800 Subject: [PATCH] feat(mail): add --all flag to 'gt mail inbox' command Adds --all/-a flag as a semantic complement to --unread. While the default behavior already shows all messages, --all makes the intent explicit when viewing the complete inbox. The flags are mutually exclusive - using both --all and --unread returns an error. Co-Authored-By: Claude Opus 4.5 --- internal/cmd/mail.go | 7 +++++++ internal/cmd/mail_inbox.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/internal/cmd/mail.go b/internal/cmd/mail.go index 3d6be4a2..623f137c 100644 --- a/internal/cmd/mail.go +++ b/internal/cmd/mail.go @@ -21,6 +21,7 @@ var ( mailInboxJSON bool mailReadJSON bool mailInboxUnread bool + mailInboxAll bool mailInboxIdentity string mailCheckInject bool mailCheckJSON bool @@ -138,8 +139,13 @@ var mailInboxCmd = &cobra.Command{ If no address is specified, shows the current context's inbox. Use --identity for polecats to explicitly specify their identity. +By default, shows all messages. Use --unread to filter to unread only, +or --all to explicitly show all messages (read and unread). + Examples: gt mail inbox # Current context (auto-detected) + gt mail inbox --all # Explicitly show all messages + gt mail inbox --unread # Show only unread messages gt mail inbox mayor/ # Mayor's inbox gt mail inbox greenplace/Toast # Polecat's inbox gt mail inbox --identity greenplace/Toast # Explicit polecat identity`, @@ -433,6 +439,7 @@ func init() { // Inbox flags mailInboxCmd.Flags().BoolVar(&mailInboxJSON, "json", false, "Output as JSON") mailInboxCmd.Flags().BoolVarP(&mailInboxUnread, "unread", "u", false, "Show only unread messages") + mailInboxCmd.Flags().BoolVarP(&mailInboxAll, "all", "a", false, "Show all messages (read and unread)") mailInboxCmd.Flags().StringVar(&mailInboxIdentity, "identity", "", "Explicit identity for inbox (e.g., greenplace/Toast)") mailInboxCmd.Flags().StringVar(&mailInboxIdentity, "address", "", "Alias for --identity") diff --git a/internal/cmd/mail_inbox.go b/internal/cmd/mail_inbox.go index 91ca4a51..2f865203 100644 --- a/internal/cmd/mail_inbox.go +++ b/internal/cmd/mail_inbox.go @@ -30,6 +30,11 @@ func getMailbox(address string) (*mail.Mailbox, error) { } func runMailInbox(cmd *cobra.Command, args []string) error { + // Check for mutually exclusive flags + if mailInboxAll && mailInboxUnread { + return errors.New("--all and --unread are mutually exclusive") + } + // Determine which inbox to check (priority: --identity flag, positional arg, auto-detect) address := "" if mailInboxIdentity != "" { @@ -46,6 +51,8 @@ func runMailInbox(cmd *cobra.Command, args []string) error { } // Get messages + // --all is the default behavior (shows all messages) + // --unread filters to only unread messages var messages []*mail.Message if mailInboxUnread { messages, err = mailbox.ListUnread()