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 <noreply@anthropic.com>
This commit is contained in:
committed by
beads/crew/emma
parent
cd347dfdf9
commit
d610d444d7
@@ -21,6 +21,7 @@ var (
|
|||||||
mailInboxJSON bool
|
mailInboxJSON bool
|
||||||
mailReadJSON bool
|
mailReadJSON bool
|
||||||
mailInboxUnread bool
|
mailInboxUnread bool
|
||||||
|
mailInboxAll bool
|
||||||
mailInboxIdentity string
|
mailInboxIdentity string
|
||||||
mailCheckInject bool
|
mailCheckInject bool
|
||||||
mailCheckJSON bool
|
mailCheckJSON bool
|
||||||
@@ -138,8 +139,13 @@ var mailInboxCmd = &cobra.Command{
|
|||||||
If no address is specified, shows the current context's inbox.
|
If no address is specified, shows the current context's inbox.
|
||||||
Use --identity for polecats to explicitly specify their identity.
|
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:
|
Examples:
|
||||||
gt mail inbox # Current context (auto-detected)
|
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 mayor/ # Mayor's inbox
|
||||||
gt mail inbox greenplace/Toast # Polecat's inbox
|
gt mail inbox greenplace/Toast # Polecat's inbox
|
||||||
gt mail inbox --identity greenplace/Toast # Explicit polecat identity`,
|
gt mail inbox --identity greenplace/Toast # Explicit polecat identity`,
|
||||||
@@ -433,6 +439,7 @@ func init() {
|
|||||||
// Inbox flags
|
// Inbox flags
|
||||||
mailInboxCmd.Flags().BoolVar(&mailInboxJSON, "json", false, "Output as JSON")
|
mailInboxCmd.Flags().BoolVar(&mailInboxJSON, "json", false, "Output as JSON")
|
||||||
mailInboxCmd.Flags().BoolVarP(&mailInboxUnread, "unread", "u", false, "Show only unread messages")
|
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, "identity", "", "Explicit identity for inbox (e.g., greenplace/Toast)")
|
||||||
mailInboxCmd.Flags().StringVar(&mailInboxIdentity, "address", "", "Alias for --identity")
|
mailInboxCmd.Flags().StringVar(&mailInboxIdentity, "address", "", "Alias for --identity")
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ func getMailbox(address string) (*mail.Mailbox, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runMailInbox(cmd *cobra.Command, args []string) 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)
|
// Determine which inbox to check (priority: --identity flag, positional arg, auto-detect)
|
||||||
address := ""
|
address := ""
|
||||||
if mailInboxIdentity != "" {
|
if mailInboxIdentity != "" {
|
||||||
@@ -46,6 +51,8 @@ func runMailInbox(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get messages
|
// Get messages
|
||||||
|
// --all is the default behavior (shows all messages)
|
||||||
|
// --unread filters to only unread messages
|
||||||
var messages []*mail.Message
|
var messages []*mail.Message
|
||||||
if mailInboxUnread {
|
if mailInboxUnread {
|
||||||
messages, err = mailbox.ListUnread()
|
messages, err = mailbox.ListUnread()
|
||||||
|
|||||||
Reference in New Issue
Block a user